一.时间转换时间戳
function transdate(endTime){
var date=new Date();
date.setFullYear(endTime.substring(0,4));
date.setMonth(endTime.substring(5,7)-1);
date.setDate(endTime.substring(8,10));
date.setHours(endTime.substring(11,13));
date.setMinutes(endTime.substring(14,16));
date.setSeconds(endTime.substring(17,19));
return Date.parse(date)/1000;
}
二.时间戳转换时间
(1):转换成 2020-11-10 08:50:00 格式:
function getDate( time){
var tt=new Date(parseInt( time) * 1000).toLocaleString().replace(/年|月/g, “-”).replace(/日/g, " ")
return tt;
}
(2):转换成 2020年11月16日 17:35:00:
function getDate( time){
var tt=new Date(parseInt( time) * 1000).toLocaleString()
return tt;
}
(3):转换成 2020年8月11日 08:50
function getDate( time){
var tt=new Date(parseInt( time) * 1000).toLocaleString().substr(0,16);
return tt;
}