Skip to main content

Is This Unix Timestamp in Seconds or Milliseconds?

Unix time is conventionally counted in seconds from the Unix epoch, but many APIs use milliseconds. Around present-day dates, seconds are about 10 digits and milliseconds about 13; confirm the contract rather than relying only on length.

The same instant in two units

seconds:      1700000000
milliseconds: 1700000000000

These represent the same instant when the consumer uses the declared unit. Passing the first value to a millisecond-based constructor yields a date close to the epoch instead.

A unit error moves the date dramatically

If a millisecond value is interpreted as seconds, the computed date may be thousands of years away or overflow the library. If a seconds value is interpreted as milliseconds, it lands in January 1970. Multiply seconds by 1000 to supply milliseconds; divide milliseconds by 1000 when an API expects seconds, while deciding deliberately how to handle any remainder.

Digit counting is a diagnostic shortcut, not a specification. Negative timestamps, early historical dates, far-future values, leading zeros, strings, and smaller custom epochs defeat the heuristic. Field names such as created_at_ms help, but the producer’s documentation and a known test value are stronger evidence.

Epoch value and displayed time zone are separate

An epoch timestamp identifies an instant. Converting it for display applies a time zone and formatting rules; changing that display zone should not change the underlying instant. By contrast, a date-time string without a zone may be ambiguous. Store or exchange a clear instant, retain the original zone when business rules depend on it, and test daylight-saving transitions when scheduling local civil time.

Identify timestamp units from magnitude and context

Typical magnitude near 2026Likely unitConvert to seconds
1,700,000,000SecondsUse as supplied
1,700,000,000,000MillisecondsDivide by 1,000
1,700,000,000,000,000MicrosecondsDivide by 1,000,000
1,700,000,000,000,000,000NanosecondsDivide by 1,000,000,000

Time conversions that silently corrupt data

JavaScript numbers cannot exactly represent every large nanosecond timestamp; use an appropriate integer or structured representation.

Unix time and UTC display are related, but leap-second handling and system clocks require care in precision-sensitive systems.

Never “fix” a suspicious production timestamp by multiplying until the date looks plausible without confirming the producer contract.

Normalize a timestamp without shifting the instant

  • Read the field or API contract and record the unit explicitly in code and documentation.
  • Test against one known UTC instant and one value with a non-zero subsecond part.
  • Check integer range and floating-point precision in the language, database, and serialization path.
  • Keep conversion and local display formatting as separate operations.

Unix timestamp unit questions

Why does my timestamp show a date in 1970?

A seconds value was likely passed to an API that expects milliseconds, making it one-thousandth of the intended offset from the epoch.

Does a Unix timestamp contain a time zone?

No. It identifies an instant relative to the epoch; a time zone is applied when formatting that instant for people.

Put the concept into practice

Try the Epoch / Unix Timestamp Converter with harmless sample data. Then connect the idea to cron timezone troubleshooting.

Definitions and standards behind the answer