what is 13 digit timestamp javascript code example

Example: get 13 digit timestamp javascript

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

Tags:

Misc Example