微信小程序的时间格式

虽然微信小程序仍在内部测试,但它不能火。看一下吧。记录学习中的点点。



有时间直接与Date.now()得到一串数字。



与util.formattime得到格式化的时间(日期)



Util是WeChat的官方演示提供的工具:下面的代码




作用时间格式化(日期){
VaR年= date.getfullyear()
VaR月= date.getmonth()+ 1
VaR天= date.getdate()

无功功率= date.gethours()
VaR分钟= date.getminutes()
无功二= date.getseconds()

返回{年,月,日}。地图(formatnumber)。加入(/)++ {小时,分钟,秒}。地图(formatnumber)。加入(':')
}




收购时间如下:





谢谢你的阅读。我希望你能帮助你,谢谢你对这个站的支持。