How to Convert a Unix Timestamp to a Date (and Back)

Computer code and clock for timestamps
Photo: “Atomic Clock016” by National Institute of Standards and Technology · Public domain · via Wikimedia Commons

Short answer

A Unix timestamp counts the seconds since 1 January 1970, 00:00:00 UTC. Divide by 86,400 to get days, or let code do it: 1800000000 is 15 January 2027, 08:00:00 UTC, which is 03:00 the same morning in Toronto (UTC−5). If the number has 13 digits it is in milliseconds, so divide by 1,000 first.

Unix timestamps appear in log files, APIs, databases, cookies and spreadsheets exported from apps. They are compact and easy for computers to compare, but a number like 1798761600 means nothing to a person until it is converted. This guide explains what the number counts, how to convert it in both directions, and the traps around milliseconds and time zones. You can paste any value into the Unix timestamp converter to check.

What a Unix timestamp is

The POSIX standard defines “seconds since the Epoch” as the number of seconds that have passed since 00:00:00 UTC on 1 January 1970, counting every day as exactly 86,400 seconds. Leap seconds are not counted, which is why the arithmetic stays simple: every day adds exactly 86,400 to the number. Times before 1970 are negative numbers.

Because the count is tied to UTC, a timestamp is the same everywhere in the world at the same instant. Only the way it is displayed changes with your time zone.

Checked examples

Timestamp (seconds)UTCToronto (local time)
01 Jan 1970, 00:00:0031 Dec 1969, 19:00:00 (UTC−5)
1,000,000,0009 Sep 2001, 01:46:408 Sep 2001, 21:46:40 (UTC−4)
1,700,000,00014 Nov 2023, 22:13:2014 Nov 2023, 17:13:20 (UTC−5)
1,798,761,6001 Jan 2027, 00:00:0031 Dec 2026, 19:00:00 (UTC−5)
1,800,000,00015 Jan 2027, 08:00:0015 Jan 2027, 03:00:00 (UTC−5)
2,147,483,64719 Jan 2038, 03:14:0718 Jan 2038, 22:14:07 (UTC−5)

The September 2001 row shows Toronto on daylight time (UTC−4); the others fall in standard time (UTC−5). The same timestamp can land on a different calendar date depending on where you read it.

Converting by hand

You rarely need to, but doing it once shows how the number works. Take 1,800,000,000:

  1. Divide by 86,400 seconds per day: 1,800,000,000 ÷ 86,400 = 20,833 whole days, with 28,800 seconds left over.
  2. 28,800 seconds ÷ 3,600 = 8 hours, so the time is 08:00:00 UTC.
  3. Count 20,833 days forward from 1 January 1970, allowing for leap years, and you reach 15 January 2027.

Step 3 is where code is far more reliable than a person, which is why every language has a built-in function.

Converting in code and spreadsheets

Seconds or milliseconds?

Count the digits. Timestamps for dates between 2001 and 2286 have 10 digits in seconds and 13 digits in milliseconds. JavaScript, Java and many web APIs use milliseconds; Unix tools, PHP and most databases use seconds. If a conversion lands tens of thousands of years in the future, or in January 1970, you almost certainly used the wrong unit.

Time zones and UTC

Convert to UTC first, then to a local zone using a named time zone such as America/Toronto or Asia/Kolkata, not a fixed offset. Named zones come from the IANA time zone database, which records when each region changes its clocks. A fixed “−5” would be wrong for Toronto during summer daylight time.

The year 2038 problem

Older systems store the timestamp as a signed 32-bit integer. Its largest value is 2,147,483,647, which is 03:14:07 UTC on 19 January 2038. One second later the number overflows and can wrap to a date in December 1901. Modern operating systems and languages use 64-bit time values, but embedded devices, old file formats and some databases may still be affected, so it is worth checking any system expected to run beyond 2037.

Common mistakes

Frequently asked questions

What is a Unix timestamp?

The number of seconds since 00:00:00 UTC on 1 January 1970, not counting leap seconds. It is the same number everywhere in the world at the same instant.

How do I convert a Unix timestamp to a date in Excel?

Use =A1/86400 + DATE(1970,1,1) and format the cell as a date. The result is in UTC; adjust by hours ÷ 24 for your time zone.

Is my timestamp in seconds or milliseconds?

For dates since 2001, 10 digits means seconds and 13 digits means milliseconds. Divide a millisecond value by 1,000 to get seconds.

What is Unix timestamp 0?

00:00:00 UTC on 1 January 1970, which was 7 pm on 31 December 1969 in Toronto.

What happens in 2038?

Systems that store time as a signed 32-bit number overflow after 2,147,483,647, which is 03:14:07 UTC on 19 January 2038. 64-bit systems are not affected.

Do Unix timestamps include leap seconds?

No. POSIX time counts every day as exactly 86,400 seconds.

Sources

Note: General technical information. All example conversions were computed with Python's datetime and zoneinfo modules on 30 November 2026.

Sources and further reading

💙 If VSH helps you, please share it and help us improve.