var timer = Date.now();console.log(timer);
var timestamp1 = Date.parse(new Date());
var timestamp2 = (new Date()).valueOf();
var timestamp3 = new Date().getTime();
console.log(timestamp1);
console.log(timestamp2);
console.log(timestamp3);
var strtime = '2014-04-23 18:55:49:123'; //把日期转换为时间戳;
var date = new Date(strtime);
console.log(date);
var date = new Date(1577688324100); //把时间戳转换为日期
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-07-05 00:30:00 发布