Code snippets / JavaScript
Get the current Unix timestamp in JavaScript
JavaScript uses millisecond-precision timestamps everywhere. `Date.now()` returns the current epoch in milliseconds, so divide by 1000 (and floor) for the classic 10-digit second value.
The `Date` object can go both directions: construct one from a timestamp, or parse an ISO 8601 string back into epoch milliseconds with `Date.parse()`.
Current Unix timestamp (seconds)
const nowSeconds = Math.floor(Date.now() / 1000);
console.log(nowSeconds); // 1,754,136,000 Current Unix timestamp (milliseconds)
const nowMs = Date.now();
console.log(nowMs); // 1,754,136,000,000 Convert epoch seconds → ISO 8601 (UTC)
new Date(1754136000 * 1000).toISOString();
// "2025-08-02T12:00:00.000Z" Convert ISO 8601 → epoch seconds
const seconds = Math.floor(new Date("2025-08-02T12:00:00.000Z").getTime() / 1000);
console.log(seconds); // 1754136000 Example values used above: epoch seconds = 1,754,136,000 · ISO 8601 = 2025-08-02T12:00:00.000Z
Need more languages? Browse all the Unix timestamp code snippets. Curious how the numbers work? See the Unix epoch time FAQ, or view the current epoch time in any timezone.
Epoch → Human Date
Try it live — convert any timestamp in JavaScript-friendly format.
Seconds or milliseconds — the unit is auto-detected. Example: 1735689600
UTC ISO 8601
–
Local — auto
–
RFC 2822 / GMT
–
Seconds value
–
Relative time
–