小程序每隔1秒更新显示时间问题
发布于 6 年前 作者 yan75 18085 次浏览 来自 问答

通过以下方法更新当前时间,ios系统有些识别不了getTime方法,获取时间显示如下图:

//获取当前时间

getTime:function() {

    var that = this;

    var nowTime = new Date;

    this.setData({

        punch: util.formatTime(new Date).substring(10, 20)

    })

    setTimeout(function () {

          that.getTime();

     }, 1000);  

},

1 回复

let date = new Date()

date.getHours()

date.getMinutes()

date.getSeconds()

回到顶部