Unix Timestamp in JavaScript
JavaScript's Date API works in milliseconds internally. Use Date.now() to get the current timestamp — divide by 1000 for seconds, or keep as-is for milliseconds.
Code Examples
Current timestamp (seconds)
Math.floor(Date.now() / 1000);
Returns the current Unix timestamp in seconds. Most REST APIs, JWT tokens, and databases expect this 10-digit format.
Current timestamp (milliseconds)
Date.now();
Returns milliseconds since epoch. This is the native JS format — used by setTimeout, performance.now(), and most browser APIs.
Convert Date string to timestamp
Math.floor(new Date("2024-06-15T12:00:00Z").getTime() / 1000);Parse any ISO 8601 date string and convert it to a Unix timestamp in seconds.
Convert timestamp back to Date
new Date(timestamp * 1000).toISOString();
Multiply by 1000 to convert seconds back to milliseconds before passing to the Date constructor.
Node.js — process.hrtime (high resolution)
const [sec] = process.hrtime(); console.log(sec); // seconds since an arbitrary time
For high-resolution timing in Node.js. Note: hrtime is relative, not Unix epoch. Use Date.now() for epoch timestamps.
Note
JavaScript uses milliseconds internally — unlike most other languages that default to seconds. When debugging API payloads, a 10-digit number is seconds; a 13-digit number is milliseconds. The converter at the top of this page auto-detects both.
Main Epoch Converter
Use the homepage when you need epoch to date, date to epoch, or a full epoch converter
This JavaScript guide shows how to create and parse Unix timestamps in code. If your next step is broader search intent like epoch converter, epoch to date, epoch time to date, or unix epoch converter, jump back to the live homepage tools to paste a raw Unix value, auto-detect seconds versus milliseconds, and copy the readable answer instantly.