Skip to content
AllYouNeed

Dates & Time

Unix timestamps: choose the unit before converting

A worked example of seconds, milliseconds, safe integers and local display in AllYouNeed.

Start with a known instant

The timestamp converter accepts whole seconds or milliseconds relative to the Unix epoch. Try these two inputs with an explicit unit:

  • 1700000000 seconds → 2023-11-14T22:13:20.000Z.
  • 1700000000000 milliseconds → the same instant.

The multiplier is 1,000, not 10,000. The ISO result ends in Z, meaning UTC; the local row formats the same instant using your device’s time zone. Changing the display zone does not change the instant.

Auto is a heuristic

This tool’s Auto mode treats values at or above 10^12 as milliseconds and smaller values as seconds. That works for many recent positive timestamps, but it cannot discover an undocumented unit. 86400000 means 1970-01-02 in milliseconds and a much later date in seconds. Negative millisecond timestamps also need an explicit unit.

Get the unit from the API, database or file format. Name fields such as created_at_ms instead of guessing from digit counts. The converter does not accept microseconds, nanoseconds, fractional seconds or a number followed by extra text.

Reproduce the example

const seconds = 1700000000;
const milliseconds = seconds * 1000;
console.log(new Date(milliseconds).toISOString());
// 2023-11-14T22:13:20.000Z
console.log(new Date(86400000).toISOString());
// 1970-01-02T00:00:00.000Z

Download the date checks and run node date-checks.mjs with a current Node.js installation. It uses built-in APIs, makes no network requests, and verifies these examples plus the time-zone cases in the companion guide. A passing run prints Date examples passed.

Check precision and range separately

JavaScript’s Number represents integers exactly only within its safe-integer range, from -(2^53 - 1) to 2^53 - 1. JSON itself does not require every implementation to use that representation. If a JSON consumer converts a very large nanosecond integer to a JavaScript number, precision may already be lost before you display it. Use a documented string representation where exact large values are required.

Date has a separate supported range: ±8,640,000,000,000,000 milliseconds. A value can be a safe integer and still lie outside that range. The converter rejects invalid whole-number inputs and dates outside its supported range rather than interpreting only an initial numeric prefix.

Dates and clocks answer different questions

The date-to-timestamp input uses the device’s local zone. Around a daylight-saving transition, a wall-clock time may be missing or repeated; JavaScript applies its defined disambiguation behavior. For logs and API examples, provide an explicit offset or Z when parsing a text date.

Unix/POSIX-style timestamps do not represent leap seconds as a separate additional second in the count. A wall clock can also be adjusted. Do not use successive wall-clock readings as a substitute for a monotonic elapsed-time measurement or as proof of ordering across machines.

The signed 32-bit seconds boundary is 2147483647, or 2038-01-19T03:14:07.000Z. This is a storage/ABI limit in systems using that representation, not a limit of this browser converter. Check the actual type and platform rather than assuming every old or new system behaves alike.

Sources

Related tools

By ·