1// Define a time object dt, and then demonstrate various ways of converting dt to timestamp
2var dt = new Date("2019-07-04 23:59:59.999");
3
4 // Write method one, accurate to the millisecond, get 13-bit timestamp 1562255999999
5console.log(dt.getTime());
6
7 // Writing method two, accurate to the millisecond, get 13-bit timestamp 1562255999999
8console.log(dt.valueOf());
9
10 // Writing method three, accurate to the millisecond, get 13-bit timestamp 1562255999999
11console.log(Number(dt));
12
13 // Writing method four, accurate to the millisecond, get 13-bit timestamp 1562255999999
14console.log(+dt);
15
16 // Write five, accurate to the second, get 13-digit timestamp 1562255999000, the last three digits are fixed as 000
17console.log(Date.parse(dt));