//第一种2 function getLocalTime(nS) { 3 return new Date(parseInt(nS) * 1000).toLocaleString().replace(/:\d{1,2}$/,' '); 4 } 5 alert(getLocalTime(1293072805));6 //结果是2010年12月23日 10:537 //第二种 8 function getLocalTime(nS) { 9 return new Date(parseInt(nS) * 1000).toLocaleString().substr(0,17)
10 }
11 alert(getLocalTime(1293072805));
12 //第三种 格式为:2010-10-20 10:00:00
13 function getLocalTime(nS) {
14 return new Date(parseInt(nS) * 1000).toLocaleString().replace(/年|月/g, "-").replace(/日/g, " ");
15 }
16 alert(getLocalTime(1177824835));
转载于:https://www.cnblogs.com/web-chuanfa/p/9345775.html