两个时间差

js

Page({

onLoad: function () {

var that = this

setInterval(function () {

var t1 = new Date("2018/12/15 00:00:00")

var t2 = new Date()

// console.log(t2)

var tt=t2-t1;

console.log((new Date(tt) / 1000 / 3600 / 24));

var t = new Date(t2 - t1 + 16 * 3600 * 1000)

that.setData({

d: parseInt((new Date(tt) / 1000 / 3600 / 24)-1),

h: t.getHours(),

m: t.getMinutes(),

s: t.getSeconds()

})

}, 1000)

}

})

WXML

<text>已经

{{d}}天{{h}}时{{m}}分{{s}}秒</text>

原创文章 12 获赞 9 访问量 7万+

猜你喜欢

转载自blog.csdn.net/weixin_42120669/article/details/81474974