Skip to content
ENID
Developer

Unix Timestamp Explained: Epoch Time, Seconds vs Milliseconds

What a Unix timestamp is, how seconds and milliseconds differ, how time zones fit in, and the mistakes that cause off-by-hours bugs.

Published 3 min read

What a Unix timestamp is

A Unix timestamp is the number of seconds that have passed since 1 January 1970 at 00:00:00 UTC, a moment called the Unix epoch. At the time of writing it is a ten-digit number around 1.7 billion. Because it is a single number counted from a fixed point in UTC, it identifies the same instant everywhere in the world.

Seconds, milliseconds, microseconds

Different systems count in different units. The magnitude gives it away:

Digits (today)UnitCommon in
10SecondsUnix tools, PHP time(), JWT claims
13MillisecondsJavaScript Date.now(), Java, many APIs
16MicrosecondsSome databases and logging systems

Mixing them is the most common bug: a millisecond value read as seconds gives a date tens of thousands of years in the future.

Time zones

A timestamp itself has no time zone. The zone only appears when you turn it into a calendar date. The same timestamp is a different clock time in Jakarta, London, and New York, but it is the same instant. Store and exchange timestamps or UTC dates, and convert to a local time only when showing them to a person.

ISO 8601

When a readable form is needed, use ISO 8601, for example 2026-11-18T09:00:00Z. The Z means UTC, and an offset such as +07:00 says the local offset. It sorts correctly as text and is understood by almost every language.

Getting the current timestamp

JavaScript:  Math.floor(Date.now() / 1000)
Python:      int(time.time())
PHP:         time()
Bash:        date +%s

Converting

The Unix Timestamp & Epoch Converter turns a number into UTC, local time, and ISO 8601, and turns a date back into seconds and milliseconds. Enter the value and, if the result looks wrong, choose the unit yourself instead of using auto-detect.

Pitfalls

  • Wrong unit. Check the digit count first.
  • Local time stored as if it were UTC. This gives errors of exactly your offset in hours.
  • Daylight saving time. Adding 24 hours is not the same as adding one calendar day around a clock change.
  • The year 2038 problem. A signed 32-bit integer holding seconds overflows on 19 January 2038. Use 64-bit integers.
  • Leap seconds. Unix time ignores them, so it is not a count of every real second.

Timestamps in the wild

JWT claims such as exp and iat are Unix seconds, which is why reading a JWT often needs a conversion. Server logs and databases also commonly store epoch values.

FAQ

Why is the epoch 1970?

It was a convenient start date chosen by early Unix developers and has stayed the standard.

Are timestamps affected by my time zone?

The number is not. Only the readable date you see changes with the zone.

Which unit should my API use?

Pick one, document it clearly, and keep it consistent. ISO 8601 strings are friendlier when humans read the data.

Related guides

Enter to open, Esc to close

Scroll to Top