Unix Timestamps in JavaScript

Convert between Unix seconds, JavaScript milliseconds and readable dates without mixing up timestamp units.

By Lumarc Studio · Updated 2026-07-29

Unix time counts elapsed time since 1970-01-01T00:00:00Z. Many APIs store Unix timestamps as seconds, while JavaScript Date uses milliseconds.

That unit difference causes a lot of bugs.

const seconds = 1700000000;
const date = new Date(seconds * 1000);

If you forget the * 1000, JavaScript interprets the value as milliseconds and returns a date near January 1970.

Seconds vs Milliseconds

A Unix timestamp in seconds is usually 10 digits for modern dates. A JavaScript timestamp in milliseconds is usually 13 digits.

Date.now(); // milliseconds
Math.floor(Date.now() / 1000); // Unix seconds

The Unix Timestamp Converter accepts either shape and shows UTC, local time, seconds and milliseconds.

UTC and Local Time

Unix timestamps are timezone-independent instants. Formatting them as local time depends on the viewer’s environment. For logs and APIs, UTC is usually the safest representation.

Limitations

JavaScript’s Date model does not represent leap seconds. For most web applications, logging systems and API timestamps, that is acceptable, but high-precision time systems may need specialized libraries.

Related tools

Related guides