> codebench_TOOL: HomeLOCAL-ONLY⌘K Switch

Unix Timestamps: Convert Seconds and Milliseconds Across Time Zones

Convert Unix timestamps without guessing the unit. See how seconds, milliseconds, UTC, and local time describe the same instant.

·3 min readAbout the maintainer

A log says an event happened on January 1, 2026. You paste its timestamp into a converter and get January 1970. The clock was probably fine. The number was in seconds, but the converter read it as milliseconds.

What a Unix timestamp measures

The Unix epoch is 1970-01-01T00:00:00Z. A Unix timestamp in seconds counts time from that point, with leap seconds not counted. Zero is the epoch; negative values point to times before it. Some systems use the same origin but count milliseconds instead.

Unit Timestamp Same instant in UTC
Seconds 1767225600 2026-01-01T00:00:00.000Z
Milliseconds 1767225600000 2026-01-01T00:00:00.000Z

Multiply seconds by 1,000 to get milliseconds. Divide by 1,000 to go the other way. If the receiver wants whole seconds, check its rounding convention. For example, rounding down puts -1 millisecond in second -1, not second 0.

Current dates tend to be 10 digits in seconds and 13 in milliseconds. That is a useful clue, not a rule: values near the epoch are short in both units, and some systems send microseconds instead. Check the API or schema before converting. When you own the schema, a field like created_at_ms makes the unit hard to miss.

Why the same instant can have two dates

The timestamp does not store a time zone. A time zone changes how you display an instant, not when it happened. These strings point to the same instant:

2026-01-01T00:00:00Z
2025-12-31T19:00:00-05:00

Z means UTC. The second string gives a clock reading five hours behind UTC, so it lands on the previous calendar day. That is the expected reading in New York at this instant. But -05:00 is an offset, not a time zone: New York also uses -04:00 during daylight saving time. Use a named zone like America/New_York when you need its rules across dates.

The reverse conversion is where ambiguity creeps in. In JavaScript, an ISO date-time like 2026-01-01T00:00:00 without an offset is interpreted in the host's local zone. Two machines can turn it into different timestamps. A date-only ISO string like 2026-01-01 is parsed as UTC by JavaScript, but that does not mean a birthday or billing date should be stored as a timestamp. A calendar date is not necessarily an instant.

Try both directions

  1. Open Unix Timestamp. In Timestamp → Date, select Seconds and enter 1767225600. The ISO 8601 result is 2026-01-01T00:00:00.000Z. The Local result depends on your browser's time zone.
  2. Switch to Milliseconds without changing the input. The ISO result jumps to 1970-01-21T10:53:45.600Z. Enter 1767225600000 to get back to 2026.
  3. In Date → Timestamp, enter 2025-12-31T19:00:00-05:00. You get the same original values in seconds and milliseconds. Try 2026-01-01T00:00:00.250Z next: the millisecond result is 1767225600250, while the whole-second result stays 1767225600.

To compare named zones without changing your browser settings, paste 2026-01-01T00:00:00Z into the Date Formatter. Switch the time zone from UTC to America/New_York and compare the Locale row. The Unix values stay fixed while the displayed date changes.

Summary

  • Check the unit at the source. Being off by a factor of 1,000 can still produce a valid date.
  • Use an explicit offset or Z when sharing a date-time that represents an instant.
  • Use a named zone for local display across dates, and keep the timestamp unchanged.

For the underlying conventions, see POSIX Seconds Since the Epoch and the ECMAScript Date Time String Format.

#unix#timestamp#datetime#timezones
> codebench $Ctrl+Enter Run