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>