Current Unix timestamp in JavaScript

Math.floor(Date.now() / 1000)

Math.floor(Date.now() / 1000) is the current Unix time in seconds. Date.now() on its own counts milliseconds since 1970-01-01T00:00:00Z, so it has three more digits than the seconds that date +%s, most databases and JWT exp claims (RFC 7519) use.

const ms = Date.now();
console.log(ms);
console.log(Math.floor(ms / 1000));
console.log(new Date(ms).toISOString());
1792021403988
1792021403
2026-10-14T23:43:23.988Z

That’s one run in Node 22; browsers, Deno and Bun return the same kind of number. The tool below starts on that run’s milliseconds with its clock fixed at 2026-10-14T23:43:23.988Z: it reads the 13 digits as milliseconds and shows the same ISO time. Once the page has loaded, Current Unix time shows your own clock.

Back to a date

Date takes milliseconds, so multiply seconds by 1000. Forgetting to is the classic bug, and the date lands in January 1970:

new Date(1700000000 * 1000).toISOString();               // 2023-11-14T22:13:20.000Z
new Date(1700000000).toISOString();                      // 1970-01-20T16:13:20.000Z
Math.floor(Date.parse('2024-03-10T07:30:00Z') / 1000);   // 1710055800

Gotchas

Floor, don’t round. Date.now() / 1000 is a fraction like 1792021404.055, and Math.round turns anything from half a second up into a second that hasn’t started yet: Math.round(1700000000.6) is 1700000001.

| 0 stops working in 2038. Bitwise operators convert to a signed 32-bit integer, so the shortcut wraps one second after 2038-01-19T03:14:07Z. Math.floor doesn’t:

(2147483647000 / 1000) | 0;   // 2147483647
(2147483648000 / 1000) | 0;   // -2147483648

A date string without an offset isn’t always UTC. ECMAScript reads a date-only string as UTC but a date and time without an offset as local time. Run with TZ=America/New_York:

new Date('2024-03-10').toISOString();         // 2024-03-10T00:00:00.000Z
new Date('2024-03-10T00:00').toISOString();   // 2024-03-10T05:00:00.000Z

Put Z or an offset on every string you parse. toString() uses the machine’s zone too (Tue Nov 14 2023 17:13:20 GMT-0500 (Eastern Standard Time) for 1700000000); toISOString() is always UTC.

Date.now() follows the wall clock, which NTP or a person can move. Time a duration with performance.now(), which only goes forward.

Temporal

Where the Temporal API exists, Temporal.Now.instant().epochMilliseconds is the same count, so the seconds are still Math.floor(Temporal.Now.instant().epochMilliseconds / 1000). Temporal.Instant has no epochSeconds. The Chromium 153 and WebKit 26.6 builds used to check this page have Temporal; Node 22 doesn’t.

Try it in the Unix Timestamp Converter

Current Unix time

Your browser's clock shows the current time here once the page loads.

2026-10-14 23:43:23 UTC (UTC+00:00)

Seconds1792021403.988
Milliseconds1792021403988
ISO 8601 (UTC)2026-10-14T23:43:23.988Z
Day of the weekWednesday
Read asmilliseconds since the epoch
Relative to nownow

Runs in your browser. Nothing you enter is sent anywhere.