首页 > 微信 > 详细

微信小程序时钟(xx年xx月xx日xx:xx格式)

时间:2018-07-17 20:10:23      阅读:229      评论:0      收藏:0      [点我收藏+]

wxml:

<view>时间:{{newTime}}</view>

js:

page({
    data:{
        newTime:‘‘
    },
    onLoad: function (options) {
    var that = this;
    //获取实时时间
    setInterval(function () {
      var nowTime = new Date();
      var hour = nowTime.getHours();
      var minutes = nowTime.getMinutes();
      if (hour < 10) {
        hour = "0" + hour;
      }
      if (minutes < 10) {
        minutes = "0" + minutes;
      }
      //console.log("nowTime:",nowTime)
      that.setData({
        newTime: nowTime.getFullYear() + ‘年‘ + (nowTime.getMonth() + 1) + ‘月‘ + nowTime.getDate() + "日" + hour + ‘:‘ + minutes
      })
    }, 200)
  },
})    

  

微信小程序时钟(xx年xx月xx日xx:xx格式)

原文:https://www.cnblogs.com/hj0711/p/9325538.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!