Example 1 — Read the Epoch Milliseconds
Call valueOf() on a UTC-built Date (MDN-style example).
const date1 = new Date(Date.UTC(96, 1, 2, 3, 4, 5));
console.log(date1.valueOf());
// 823230245000
const date2 = new Date("02 Feb 1996 03:04:05 GMT");
console.log(date2.valueOf());
// 823230245000 How It Works
- Build the same instant two ways.
Date.UTCparts and a GMT string both mean Feb 2, 1996 03:04:05 UTC. - Call
valueOf(). EachDatereturns its internal timestamp as a number. - Same result. Both print
823230245000because they store the same instant. - Unit. The value is milliseconds since the Unix epoch — not a formatted date string.

