1. Time conversion timestamp
Copy the code code as follows:
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;
}
2. Timestamp conversion time
(1): Converted to 2011-3-16 16:50:43 format:
Copy the code code as follows:
function getDate(tm){
var tt=new Date(parseInt(tm) * 1000).toLocaleString().replace(/year|month/g, "-").replace(/日/g, " ")
return tt;
}
(2): converted to March 16, 2011 16:50:43:
Copy the code code as follows:
function getDate(tm){
var tt=new Date(parseInt(tm) * 1000).toLocaleString()
return tt;
}
(3): Converted to 16:50 on March 16, 2011
Copy the code code as follows:
function getDate(tm){
var tt=new Date(parseInt(tm) * 1000).toLocaleString().substr(0,16);
return tt;
}