小程序体验版在iOS上时间显示NaN?,在开发工具的真机测试时间显示正确?
// var time = Date.parse(date); // console.log(time); // var date = new Date(time); var year = date.getFullYear() var month = date.getMonth() + 1 var day = date.getDate() var hour = date.getHours() var minute = date.getMinutes() var second = date.getSeconds() return [year, month, day].map(formatNumber).join( '/' );
item.createTime = util.formatTime(item.createTime) item.transportationTime = util.formatTime(item.transportationTime) item.validityPeriod = util.formatTime(item.validityPeriod) item.updateTime = item.updateTime == null ? "" : util.formatTime(item.updateTime) |
我传到formattime里面的事Wed Aug 19 2020 09:57:13 GMT-0400 没法用replace 这个怎么办,formattime最后有一个join("/")为什么不work 呢?
我也遇到了这个问题,请问解决了嘛?
function formatTime(date) {
var time = date==null?"": Date.parse(date.replace(/-/g, '/'));
var date = new Date(time);
var year = date.getFullYear();
var month = date.getMonth() + 1;
var day = date.getDate();
var hour = date.getHours();
var minute = date.getMinutes();
var second = date.getSeconds();
return [year, month, day].map(formatNumber).join('/');
}
function formatTime(date) {
var year = date.getFullYear()
var month = date.getMonth() + 1
var day = date.getDate()
var hour = date.getHours()
var minute = date.getMinutes()
var second = date.getSeconds()
return [year, month, day].map(formatNumber).join('/');
}
function formatTime(date) {
var time = date==null?"": Date.parse(date.replace(/-/g, '/'));
console.log(time)
var date = new Date(time);
var year = date.getFullYear();
var month = date.getMonth() + 1;
var day = date.getDate();
var hour = date.getHours();
var minute = date.getMinutes();
var second = date.getSeconds();
return [year, month, day].map(formatNumber).join('/');
}