//第一种 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:53 7 //第二种 ????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:0013 ????function getLocalTime(nS) { ????14 ???????return new Date(parseInt(nS) * 1000).toLocaleString().replace(/年|月/g, "-").replace(/日/g, " "); ?????15 ????} ????16 ????alert(getLocalTime(1177824835));
js时间戳转成日期格式
原文地址:https://www.cnblogs.com/web-chuanfa/p/9345775.html