function formateTimeStamp(time){
var date = new Date();
date.setTime(time);
var year = date.getFullYear();
var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
var day = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
var hour = date.getHours()< 10 ? "0" + date.getHours() : date.getHours();
var minute = date.getMinutes()< 10 ? "0" + date.getMinutes() : date.getMinutes();
var second = date.getSeconds()< 10 ? "0" + date.getSeconds() : date.getSeconds();
return year + "-" + month + "-" + day+" "+hour+":"+minute+":"+second;
}
以上代码显示出"yyyy-MM-dd HH24:mm:ss"格式的字符串。可以根据不同需求改变显示的格式。