Is this Unix timestamp in seconds or milliseconds?

The same moment can be 1700000000 or 1700000000000. Count the digits and you will know which one you have.

Count the digits

DigitsUnitTypical source
10secondsUnix tools, date +%s, PHP time(), JWT claims, most APIs
13millisecondsJavaScript Date.now(), Java System.currentTimeMillis()
16microsecondsSome databases and tracing tools
19nanosecondsGo time.Now().UnixNano()

If a date comes out in January 1970, you passed seconds where milliseconds were expected. If it lands tens of thousands of years in the future, it is the other way round. The Unix time converter guesses the unit for you.

Converting

# Linux (GNU date)
date -u -d @1700000000
# macOS
date -u -r 1700000000
# now, in seconds
date +%s
// JavaScript: Date wants milliseconds
new Date(1700000000 * 1000).toISOString()
Math.floor(Date.now() / 1000)   // now, in seconds
# Python: time.time() is seconds, as a float
from datetime import datetime, timezone
datetime.fromtimestamp(1700000000, tz=timezone.utc)

Time zones do not apply

A Unix timestamp counts seconds since 1 January 1970 at midnight UTC, so it is the same number everywhere on Earth at the same moment. Time zones only matter when you turn it into a clock time for a person.

The year 2038 problem

Systems that store seconds in a signed 32-bit integer run out at 2147483647, which is 19 January 2038, 03:14:07 UTC. One second later the number wraps to a negative value and reads as December 1901. Most modern systems use 64 bits and are fine, but old embedded devices, file formats and database columns can still be caught out. Leap seconds, by the way, are not counted: Unix time pretends every day has exactly 86,400 seconds.

Related

How many working days in the UK · KB vs KiB / MB vs MiB · C ↔ F ↔ K

Questions

How many digits is a Unix timestamp?

In seconds, 10 digits for any date from September 2001 until November 2286. In milliseconds, 13 digits for the same range.

Is Unix time UTC?

Yes. It counts from midnight UTC on 1 January 1970 and has no time zone of its own.

What happens in 2038?

Signed 32-bit timestamps overflow at 03:14:07 UTC on 19 January 2038. Software that still uses them will show wrong dates; 64-bit timestamps last for billions of years.

Published .

Try it

Related guides

Newest guides