第一种
functiongetLocalTime(nS) {returnnewDate(parseInt(nS) * 1000).toLocaleString().replace(/:\d{1,2}$/,' ');functiongetLocalTime(nS) {returnnewDate(parseInt(nS) * 1000).toLocaleString().replace(/:\d{1,2}$/,' ');
第二种
functiongetLocalTime(nS) {returnnewDate(parseInt(nS) * 1000).toLocaleString().substr(0,17)}
alert(getLocalTime(1293072805));
第三种
functionformatDate(now) {varyear=now.getYear();varmonth=now.getMonth()+1;vardate=now.getDate();varhour=now.getHours();varminute=now.getMinutes();varsecond=now.getSeconds();returnyear+"-"+month+"-"+date+" "+hour+":"+minute+":"+second;
}vard=newDate(1230999938);
alert(formatDate(d));
第四种 时间戳转换相应类型日期
getdate:function(value) {
varnow =newDate(parseInt(value) *1000);
varyear = now.getFullYear();
varmonth = now.getMonth() +1;
vardate = now.getDate();
varhour = now.getHours();
varminute = now.getMinutes();
varsecond = now.getSeconds();
return month +"."+ date;
}
第五种
//时间转换
functiongetLocalTime(timestamp) {
vartime =newDate(timestamp);
varyear = time.getFullYear();
varmonth = (time.getMonth() +1) >9&& (time.getMonth() +1) || ('0'+ (time.getMonth() +1))
vardate = time.getDate() >9&& time.getDate() || ('0'+ time.getDate())
varhour = time.getHours() >9&& time.getHours() || ('0'+ time.getHours())
varminute = time.getMinutes() >9&& time.getMinutes() || ('0'+ time.getMinutes())
varsecond = time.getSeconds() >9&& time.getSeconds() || ('0'+ time.getSeconds())
varYmdHis = year +'.'+ month +'.'+ date
/* + ' ' + hour + ':' + minute + ':' + second;*/
returnYmdHis;
}