第一种
function getLocalTime(nS) { return new Date(parseInt(nS) * 1000).toLocaleString().replace(/:\d{1,2}$/,‘ ‘); } alert(getLocalTime(1293072805));
function getLocalTime(nS) { return new Date(parseInt(nS) * 1000).toLocaleString().substr(0,17)} alert(getLocalTime(1293072805));
第二种
function formatDate(now) {
var year=now.getYear();
var month=now.getMonth()+1;
var date=now.getDate();
var hour=now.getHours();
var minute=now.getMinutes();
var second=now.getSeconds();
return "20"+year+"-"+month+"-"+date+" "+hour+":"+minute+":"+second;
}
var d=new Date(1230999938);
alert(formatDate(d));
原文:http://www.cnblogs.com/sure2016/p/5978062.html