On-device AI — professional-grade, fully private.

Documents

Unix Timestamps Explained: How to Convert Epoch Time to a Date (and Back)

A Unix timestamp is the number of seconds since 1 January 1970 UTC. Here is how to read one, how to tell seconds from milliseconds at a glance, and how to avoid the time-zone mistakes that come with them.

Updated October 22, 20265 min read

If you have ever opened a log file, a database export or an API response and found a number like 1792670400 where a date should be, you have met a Unix timestamp. Computers love them: one plain number, no time zone, no daylight saving, no arguing about whether 03/04 means March or April. People find them unreadable. Converting one takes a second — as long as you know which kind of timestamp you are looking at.

What a Unix timestamp actually is

A Unix timestamp counts the seconds that have passed since midnight UTC on 1 January 1970 — a moment called the Unix epoch. 0 is that midnight, 86400 is exactly one day later, and 1792670400 is 22 October 2026 at 12:00 UTC. Times before 1970 are negative numbers.

Because the count is always in UTC, a timestamp means the same instant everywhere on Earth. The number does not change when you fly to Tokyo; only the way it is *displayed* as a local date and time does. That is precisely why systems store time this way and convert to local time only at the last moment, for a person to read.

Seconds, milliseconds, microseconds: count the digits

Not every system counts in seconds. JavaScript and Java use milliseconds; some databases and logging systems use microseconds or nanoseconds. Feeding a millisecond timestamp into a seconds converter produces a date tens of thousands of years in the future. The fastest way to tell them apart is the number of digits for a present-day date:

Digits (today)UnitExampleTypical source
10Seconds1792670400Unix tools, PHP, Python time.time(), most APIs
13Milliseconds1792670400000JavaScript Date.now(), Java, many JSON APIs
16Microseconds1792670400000000PostgreSQL internals, some log formats
19Nanoseconds1792670400000000000Go, high-resolution tracing, InfluxDB

The Unix timestamp converter detects the unit from the length, so pasting any of the four gives the right date — but it is still worth knowing, because a wrong guess in your own code is a classic bug.

Converting a timestamp, step by step

1

Paste the number

Copy the timestamp exactly, without quotes or a trailing comma. The converter shows the unit it detected.

2

Read it in UTC first

The UTC result is the unambiguous truth. If it looks wrong, the unit is wrong — not the time zone.

3

Then show it in the zone you need

Choose a time zone to see the local date and time. For anything involving several places, see converting time zones.

4

Going the other way

To turn a date into a timestamp, enter the date, the time and — critically — the time zone it was in. The same wall-clock time in New York and London is two different timestamps.

Epoch to date and date to epoch, with seconds, milliseconds, microseconds and nanoseconds detected automatically and any time zone shown. Free, and it runs in your browser.

Convert a Unix timestamp

The time-zone mistake everyone makes once

A timestamp has no time zone, but the code that creates one often assumes one. The classic failure: someone turns "2026-10-22 09:00" into a timestamp on a server set to UTC, while the person meant 09:00 in New York. The stored instant is then four or five hours off, and every report built on it is wrong by the same amount.

  • Always state the zone when converting a date to a timestamp. "09:00" is not a moment; "09:00 New York" is.
  • Store timestamps, display local times. Keep UTC numbers in databases and convert only when showing them to a person.
  • Write dates in ISO 8601 when they must be text. 2026-10-22T13:00:00Z or 2026-10-22T09:00:00-04:00 carry their offset with them; 22/10/2026 9:00 does not.

Timestamps in spreadsheets

Excel and Google Sheets do not use Unix time; they count days since 1900 (or 1904 on old Macs). To convert a seconds timestamp in cell A1 into a spreadsheet date, divide by 86,400 (seconds in a day) and add the spreadsheet's date for 1 January 1970:

=A1/86400 + DATE(1970,1,1) — then format the cell as a date and time. For milliseconds, divide by 86,400,000 instead. The result is in UTC; add or subtract hours for a local zone. For more spreadsheet pitfalls, see opening CSV files in Excel correctly.

Useful reference points

Timestamp (seconds)Date (UTC)Why it matters
01 Jan 1970, 00:00The Unix epoch itself
10000000009 Sep 2001, 01:46The first 10-digit timestamp
170000000014 Nov 2023, 22:13A handy recent landmark
200000000018 May 2033, 03:33The next round number
214748364719 Jan 2038, 03:14The largest value a signed 32-bit integer holds

The year 2038 problem

Older systems stored timestamps in a signed 32-bit integer, whose maximum is 2,147,483,647 — 03:14:07 UTC on 19 January 2038. One second later, such a counter overflows and jumps back to 1901. Modern operating systems and languages use 64-bit time and are safe for billions of years, but embedded devices, old file formats and legacy databases can still carry 32-bit fields. If you maintain anything that stores dates far into the future — mortgages, certificates, warranties — it is worth checking now.

Leap seconds and other fine print

Unix time pretends every day has exactly 86,400 seconds, so it quietly ignores the leap seconds occasionally added to UTC. For almost every purpose this is what you want — dates line up with calendars and clocks. It only matters for scientific timing or systems that need sub-second accuracy across a leap second, which have their own time scales.

Timestamps in code

Most languages make the conversion one line: JavaScript new Date(1792670400 * 1000).toISOString() (note the × 1000, because JavaScript uses milliseconds), Python datetime.fromtimestamp(1792670400, tz=timezone.utc), and SQL databases offer functions such as to_timestamp() in PostgreSQL or FROM_UNIXTIME() in MySQL. The most common bug in every language is the same: mixing seconds and milliseconds, or creating a date in the server's local zone when UTC was meant.

Frequently asked questions

How do I convert a Unix timestamp to a date?

Paste it into the Unix timestamp converter. It detects whether the number is in seconds, milliseconds, microseconds or nanoseconds from its length, shows the date in UTC, and lets you display it in any time zone.

Why does my timestamp convert to a date thousands of years away?

It is almost certainly in milliseconds (13 digits) and was read as seconds. Divide by 1,000, or use a converter that detects the unit automatically.

Is a Unix timestamp in UTC or local time?

Always UTC. A timestamp names one instant for the whole world; only its display as a local date and time depends on the time zone you choose.

How do I convert a timestamp in Excel?

For seconds in A1, use =A1/86400 + DATE(1970,1,1) and format the cell as a date and time; for milliseconds divide by 86,400,000. The result is UTC, so adjust by your zone's offset if you need local time.

Keep reading

More in Documents →