毫秒字符串转日期函数javascript
just
posted @ 2009年9月07日 16:59
in web
, 3568 阅读
millisecondsStrToDate("1252225225000")
function millisecondsStrToDate(str){
var startyear = 1970;
var startmonth = 1;
var startday = 1;
var d, s;
var sep = ":";
d = new Date();
d.setFullYear(startyear, startmonth, startday);
d.setTime(0);
d.setMilliseconds(str);
s = d.getYear() + "-" + (d.getMonth()+1) + "-" + d.getDate() + " " +
d.getHours() + ":" + d.getMinutes() + ":" + d.getSeconds();
//alert(d.toLocaleString());
return d.toLocaleString();
}
var startyear = 1970;
var startmonth = 1;
var startday = 1;
var d, s;
var sep = ":";
d = new Date();
d.setFullYear(startyear, startmonth, startday);
d.setTime(0);
d.setMilliseconds(str);
s = d.getYear() + "-" + (d.getMonth()+1) + "-" + d.getDate() + " " +
d.getHours() + ":" + d.getMinutes() + ":" + d.getSeconds();
//alert(d.toLocaleString());
return d.toLocaleString();
}