js如何将数字串转为日期?
数据库查询日期前台显示为1587571200000如何转化为yyyy-MM-ddhh:mm:ss格式...
数据库查询日期前台显示为1587571200000 如何转化为yyyy-MM-dd hh:mm:ss 格式
展开
1个回答
展开全部
function convert24(val){
if(val<10){
val = "0" + val;
}
return val;
}
var miTime = 1587571200000;
var dd = new Date(miTime );
var dateStr12 = dd.getFullYear() + "-" + dd.getMonth() + "-" + dd.getDate() + " " + dd.getHours() + ":" + dd.getMinutes() + ":" + dd.getSeconds();//12小时制格式显示
var dateStr24 = dd.getFullYear() + "-" + convert24(dd.getMonth()) + "-" + convert24(dd.getDate()) + " " + convert24(dd.getHours()) + ":" + convert24(dd.getMinutes()) + ":" + convert24(dd.getSeconds());//24小时制格式显示
if(val<10){
val = "0" + val;
}
return val;
}
var miTime = 1587571200000;
var dd = new Date(miTime );
var dateStr12 = dd.getFullYear() + "-" + dd.getMonth() + "-" + dd.getDate() + " " + dd.getHours() + ":" + dd.getMinutes() + ":" + dd.getSeconds();//12小时制格式显示
var dateStr24 = dd.getFullYear() + "-" + convert24(dd.getMonth()) + "-" + convert24(dd.getDate()) + " " + convert24(dd.getHours()) + ":" + convert24(dd.getMinutes()) + ":" + convert24(dd.getSeconds());//24小时制格式显示
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询