1. Time conversion timestamp
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:
function getDate(tm){
var tt=new Date(parseInt(tm) * 1000).toLocaleString().replace(/year| Month/g, "-").replace(/日/g, " ")
return tt;
}
(2): Convert to March 16, 2011 16:50:43:
function getDate(tm){
var tt=new Date(parseInt(tm) * 1000).toLocaleString()
return tt;
}
(3): Convert to March 16, 2011 16:50
function getDate(tm){
var tt=new Date(parseInt(tm) * 1000).toLocaleString().substr(0,16);
return tt;
}
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn