1.时间转换成时间戳:
const data=new Date("2000-01-01 00:00:00");
console.log(data); //Sat Jan 01 2000 00:00:00 GMT+0800 (GMT+08:00)
console.log(data * 1); //946656000000
console.log(Number(data)); //946656000000
console.log(data.valueOf()); //946656000000
console.log(data.getTime()) //946656000000
2.时间戳转换成时间格式:
let time = 946656000000; //时间戳
console.log(new Date(time)) //Sat Jan 01 2000 00:00:00 GMT+0800 (GMT+08:00)