JS日期格式的转换

⼀Date(1330912983320)⼀这个怎么转换
2024-11-20 00:45:13
推荐回答(2个)
回答1:

var d = new Date();
d.setTime(1330912983320);
var year = d.getFullYear();
var month = d.getMonth()+1;
var date = d.getDate();

var hour = d.getHours();
var minute = d.getMinutes();
var second = d.getSeconds();
alert(year+"-"+month+"-"+date+" "+hour+":"+minute+":"+second);
你可以在判断下如果月日时小于10前边加个0

回答2:

这样试试:

var d = new Date();
d.setTime(77771564221);
document.write(d);