var timestamp1 = Date.parse(new Date());
console.log(timestamp1); //输出当前时间的时间戳
var date = new Date(1520324618000);
console.log(date);
Y = date.getFullYear() + '-';
M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-';
D = date.getDate() + ' ';
h = date.getHours() + ':';
m = date.getMinutes() + ':';
s = date.getSeconds();
console.log(Y+M+D+h+m+s);
js时间戳和普通时间相互转换
最新推荐文章于 2024-04-08 18:44:25 发布