Node.js and browser
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 Real-world use cases for JavaScript
- Storing event timestamps as seconds in a database so they are timezone-independent and sort correctly.
- Setting an auth token expiry by adding a TTL to Date.now() and comparing against it on the server.
- Converting API responses that return ISO 8601 strings into epoch seconds for charting and analytics.
| Unix timestamp (seconds) | ISO 8601 (UTC) |
|---|---|
| 0 | 1970-01-01T00:00:00.000Z |
| 946,684,800 | 2000-01-01T00:00:00.000Z |
| 1,754,136,000 | 2025-08-02T12:00:00.000Z |
| 2,147,483,647 | 2038-01-19T03:14:07.000Z |
| 2,524,608,000 | 2050-01-01T00:00:00.000Z |
These are the same fixed timestamps used in the JavaScript examples above — every conversion returns one of these values.
Frequently asked questions
How do I get the current Unix timestamp in JavaScript?
Use Math.floor(Date.now() / 1000) for seconds or Date.now() for milliseconds. Date.now() returns epoch milliseconds, so dividing by 1000 and flooring gives the classic 10-digit second value.
How do I convert an epoch timestamp to a date in JavaScript?
Pass the seconds value multiplied by 1000 to the Date constructor: new Date(1754136000 * 1000). Call .toISOString() for UTC, or use Intl.DateTimeFormat with a timeZone option for a specific timezone.
Does JavaScript handle timestamps in milliseconds or seconds?
JavaScript dates are always milliseconds internally. Functions like Date.now() and Date.parse() return milliseconds, while most databases and the Date constructor expect either. Divide by 1000 whenever you need seconds.
Epoch to human date in JavaScript
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
–
Other programming languages
Copy-paste epoch conversion snippets in your favorite stack
More timestamp guides
Example values used above: epoch seconds = 1,754,136,000 · ISO 8601 = 2025-08-02T12:00:00.000Z. Curious how the numbers work? See the Unix epoch time FAQ, or view the current epoch time in any timezone.