For Developers

Unix Timestamp in JavaScript

How to get the current timestamp, convert it to a date, and convert a date back to a timestamp in JavaScript — plus the specific mistake that trips up JavaScript code more than any other.

Date.now()
new Date(1750000000000) // pass milliseconds directly
new Date("2025-06-15T12:00:00Z").getTime()

The JavaScript-specific pitfall

JavaScript's Date is the one mainstream exception to the seconds convention — it works in milliseconds, not seconds, because it was built to match a browser's clock resolution. This is the single most common seconds/milliseconds bug in any codebase that mixes JavaScript with a backend language: a timestamp built in Python or Go and handed to JavaScript unmodified will land 1000x in the wrong place — usually sometime in 1970, or thousands of years in the future, depending on the direction of the mistake.

Have a timestamp right now?

Paste it into the Timestamp ⇄ Date Converter to check it instantly, in any timezone, without writing any code. Working across several languages on the same project? The full Epoch Time in Programming Languages guide has all of them side by side for quick comparison.

Related

Related tools & reading