1.微信小程序里如何设置当地时间?


方法一:

1.效果图

2.wxml code:

<!--pages/index/index.wxml-->
<text>当前时间:{{time}}</text>
<text>当前大时间:{{ymdtime}}</text>
<text>当前小时间:{{hmstime}}</text>

3.js code:

// pages/index/index.js
Page({
  /**
   * 页面的初始数据
   */
  data: {
    time: (new Date()).toString()
    ymdtime: (new Date()).toString().slice(0,15),
    hmstime: (new Date()).toString().slice(16, 24),      
  },
})

在此,slice()方法就是用来截取一段字符串。


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM