已经在写了如下代码,但页面时间显示依然有问题,并且都是同一个时间
var filter = {
getDateTime: function (value) {
//不能使用 new Date()
var time = getDate(value*1000);
var year = time.getFullYear();
var month = time.getMonth() + 1;
var date = time.getDate();
var hour = time.getHours();
var minute = time.getMinutes();
var second = time.getSeconds();
month = month < 10 ? "0" + month : month;
date = date < 10 ? "0" + date : date;
hour = hour < 10 ? "0" + hour : hour;
minute = minute < 10 ? "0" + minute : minute;
second = second < 10 ? "0" + second : second;
return year + "-" + month + "-" + date + " " + hour + ":" + minute + ":" + second;
},
module.exports = {
getDateTime: filter.getDateTime,
}
//wxml文件
<wxs src="../../util/util.wxs" module ="filter"/>
<text>{{filter.getDateTime(post.time)}}</text>
//保存时间戳时的方式
var time = Date.parse(new Date());
time = time / 1000;
1、可以用time = Date.now()/1000完事;
2、两条数据贴一下,post.time是一样的?应该是item.time吧?