coupon.wxs
var getDateTime = function (value) { //不能使用 new Date() console.log(value.slice(6, 19),'时间错') var values = value.slice(6, 19) values = values *1 var time = getDate(values); console.log(time,'这是转的啥') 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; return year + "." + month + "." + date // + " " + hour + ":" + minute + ":" + second;
} // 导出对外暴露的属性 module.exports = { getDateTime:getDateTime } coupon.wxml 引用 <wxs module="filter" src="./coupon.wxs"></wxs> <view>{{filter.getDateTime(item.CreationTime)}}-{{filter.getDateTime(item.ExpiredTime)}}</view>
标签:getDateTime,微信,程序,value,month,var,values,time,过滤器 From: https://www.cnblogs.com/sishe/p/17705203.html