data里的数组中每个元素都存放多个对象,其中有一个对象是时间(暂定util.formatTime(new Date)的格式,需要年月日,可以改)
想要做到时间加减(时间不定,暂定30分钟),同时想要显示在wxml(new data()的格式在前台会显示[object object],想要显示时分秒)
想问一下有没有可能让对象为new date()情况下同时解决前台只显示时分秒
或者util.formatTime(new Date)的格式在后台进行简单换算,还是说根据“:”拆分?
微信小程序关于时间运算
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
2条回答 默认 最新
qq_40471785 2021-09-16 14:02关注const time = new Date(), hour = time.getHours() > 9 ? time.getHours() : ('0' + time.getHours()), minute = time.getMinutes() > 9 ? time.getMinutes() : ('0' + time.getMinutes()), second = time.getSeconds() > 9 ? time.getSeconds() : ('0' + time.getSeconds()); console.log(hour + ':' + minute + ':' + second);本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报