function GetUtcStringFromUnixTimestamp(unixTimestamp){
var date = new Date();
// unixTimestamp += 480*60;
date.setTime(unixTimestamp * 1000);
var normaltime = date.getFullYear() + '-' + (date.getMonth()+1) + '-' + date.getDate()
+ ' ' + (date.getHours() < 10 ? ('0' + date.getHours()) : date.getHours())
+ ':' + (date.getMinutes() < 10 ? ('0' + date.getMinutes()) : date.getMinutes())
+ ':' + (date.getSeconds() < 10 ? ('0' + date.getSeconds()) : date.getSeconds());
return normaltime;
}
date.getHours() 获取的是本地的小时数而不是国际的。
图片.pngfunction date2Str(date)
{
function format(i)
{
return (i < 10) ? "0" + i : "" + i;
}
var str = format(date.getFullYear()) + "-";
str = str + format(date.getMonth()+1) + "-";
str = str + format(date.getDate()) + " ";
str = str + format(date.getHours()) + ":";
str = str + format(date.getMinutes()) + ":";
str = str + format(date.getSeconds()) + "";
return str;
}
网友评论