One Click Answers

How to convert a Unix timestamp to a date, step by step

A Unix timestamp is the number of seconds since 1 January 1970 at midnight UTC. Most of the time you would use a tool to convert one, but doing it once by hand shows exactly what the number means.

The method

  1. Divide the timestamp by 86,400, the number of seconds in a day. The whole part is the days since 1 January 1970.
  2. The remainder is how many seconds into that day it is. Divide it by 3,600 for hours, then continue for minutes and seconds.
  3. Count forward the days from 1 January 1970 to find the date.

A worked example: converting a Unix timestamp

Timestamp 1704067200

1,704,067,200 ÷ 86,400 = 19,723 days, with nothing left over

No remainder means it is exactly midnight, 12:00:00 AM UTC

19,723 days after 1 January 1970 is 1 January 2024

The same instant in another zone

The timestamp 1700000000 is 2023-11-14 10:13:20 PM in UTC. In New York, on that date, the same moment reads 5:13:20 PM. The instant did not change, only the clock used to describe it.

Seconds or milliseconds?

A 10-digit number is almost always seconds, and a 13-digit one is milliseconds. If you divide a millisecond value as though it were seconds you land absurdly far in the future. Divide by 1,000 first.

Going the other way

To turn a date into a timestamp, count the days since 1970, multiply by 86,400 and add the seconds into the day. Be clear which time zone you mean, because 12:00 AM on 1 January 2024 is a different instant in each zone.

Unix Timestamp Converter: Convert a timestamp to a date in UTC or your own zone, or turn a date back into a timestamp.

Published by OneClickAnswers.

You might also wonder...

Try it yourself

← All articles

Got another question?

Free, no account. Answers show how they were worked out.