Developer Time · How-To

How to Convert a Unix Timestamp to a Readable Date

A raw Unix timestamp is unreadable to anyone but a machine — until you know the one calculation, or the one line of code, that turns it back into a date a person can actually read.

By Reviewed 7 min read

Key takeaways

  • Manually: divide the timestamp by 86,400 (seconds in a day) for the day count, then use the remainder to work out hours, minutes, and seconds.
  • In code, it's a one-liner: new Date(ts * 1000) in JavaScript, datetime.fromtimestamp(ts, tz=timezone.utc) in Python, and similar functions in SQL and spreadsheets.
  • The most common bug is a seconds/milliseconds mismatch — feeding the wrong unit into a date function throws the answer off by a factor of 1,000.
  • Most conversion functions default to your system's local time zone unless you explicitly ask for UTC.
  • If you're not sure what unit your timestamp is in, its digit count gives it away before you convert anything.

Paste a Unix timestamp like 1735689600 into a chat message and nobody will know what date you mean. That's by design — the format exists for machines, not people — but turning it back into something readable is a five-second job once you know the method, whether you're doing it by hand or with a single line of code.

This guide walks through both: the manual arithmetic that shows exactly what's happening underneath, and working code for JavaScript, Python, SQL, and spreadsheets. If you'd rather skip straight to an answer, the Unix timestamp converter does it instantly; if you want to understand the method, keep reading.

01Before you convert anything

Two things are worth confirming first. The first is the unit: most Unix timestamps count seconds (a 10-digit number today), but plenty of systems — including JavaScript's own Date.now() — use milliseconds instead. Everything below assumes seconds unless stated otherwise; if you're not sure which you have, see the full digit-count breakdown in What Is a Unix Timestamp?

The second is the starting point: every Unix timestamp counts forward from 00:00:00 UTC on 1 January 1970, the Unix epoch. You don't need its backstory to convert a timestamp, but if you're curious why that date was chosen, it's covered in Unix Epoch Time Explained.

02The manual method, step by step

A Unix timestamp in seconds converts to a date in two stages: split it into whole days and leftover seconds, then turn the leftover seconds into a clock time and the day count into a calendar date.

  • Divide by 86,400 (the seconds in a day) and take the whole number — that's how many days have passed since 1 January 1970.
  • Whatever's left over after that division is how many seconds into that day you are.
  • Divide the remainder by 3,600 for hours, then divide what's left of that by 60 for minutes; whatever remains after both is seconds.
  • Count the day total forward from 1 January 1970, one calendar year at a time (adding an extra day for each leap year you pass), to land on the actual date.

Worked example · 1,735,689,600 → calendar date

  1. Start with 1,735,689,600 seconds since the epoch.
  2. Divide by 86,400: 1,735,689,600 ÷ 86,400 = 20,089 days exactly, with 0 seconds left over.
  3. Zero leftover seconds means the time of day is 00:00:00.
    Counting 20,089 days forward from 1 January 1970 — 55 full years, including 14 leap years (55 × 365 + 14 = 20,089) — lands exactly on 1 January 2025.

Why nobody does this by hand in production

Step 4 is the fiddly part: once your day count doesn't land on a clean year boundary, working out the exact month and day means walking through each month's length and checking for leap years along the way. That bookkeeping is exactly what the built-in functions in the next section handle for you.

03Try it: convert your own timestamp

Enter a Unix timestamp in seconds and see both the final date and the days/remainder breakdown from the method above.

Timestamp (seconds) → UTC date

—

—

Got a millisecond, microsecond, or nanosecond value instead?

This box expects seconds. See if your timestamp is in milliseconds below, or use the Unix timestamp converter, which handles every unit automatically.

04Converting in JavaScript, Python, SQL, and Excel

Every mainstream language and tool has a built-in for this, so in practice you'll rarely do the arithmetic above by hand. Here's the equivalent one-liner in each, converting the same example timestamp, 1735689600:

Converting 1,735,689,600 · one line per language
Language / toolCodeResult
JavaScriptnew Date(1735689600 * 1000).toISOString()2025-01-01T00:00:00.000Z
Python 3datetime.fromtimestamp(1735689600, tz=timezone.utc)2025-01-01 00:00:00+00:00
PostgreSQLSELECT to_timestamp(1735689600)2025-01-01 00:00:00+00
MySQLSELECT FROM_UNIXTIME(1735689600)2025-01-01 00:00:00
Excel / Google Sheets=(A1/86400)+DATE(1970,1,1)1/1/2025 0:00:00

Check which time zone you're actually getting

Several of these render their result in whatever time zone your session, server, or spreadsheet locale is configured for, not necessarily UTC. PostgreSQL's to_timestamp() and MySQL's FROM_UNIXTIME() both display in the connection's configured time zone — set that to UTC first if you need a guaranteed universal result.

05Converting to a specific local time

Once you have the UTC date and time, showing it in a particular place's local time is a matter of applying that place's offset — and almost every language will do this for you if you ask, rather than requiring you to add the offset by hand. JavaScript's Intl.DateTimeFormat and Python's zoneinfo module both accept a named time zone (such as "Asia/Karachi" or "America/New_York") and return the correctly adjusted local date and time, including daylight saving where it applies. For the concept behind why this offset step exists at all, see What Is UTC?

06If your timestamp is in milliseconds

A 13-digit timestamp is almost always milliseconds, not seconds. Divide it by 1,000 before running it through the manual method above, or, in JavaScript specifically, skip that step entirely — its Date constructor already expects milliseconds, so new Date(ts) is correct as-is for a millisecond value. For the full digit-count reference across seconds, milliseconds, microseconds, and nanoseconds, see What Is a Unix Timestamp?

07Common conversion mistakes

  • Multiplying or dividing by 1,000 incorrectly. Forgetting to convert seconds to milliseconds for JavaScript's Date, or doing it twice on a value that was already in milliseconds, is the single most common error here.
  • Calling a "local" function when you meant UTC. Python's datetime.fromtimestamp(ts) without a tz argument silently uses the system's local time zone instead of UTC.
  • Assuming a database function returns UTC. As shown above, several SQL date functions actually return the session's configured time zone.
  • Passing the wrong precision into an older function. Some legacy or embedded date functions expect a 32-bit seconds value and can overflow or error out if handed milliseconds or a timestamp far in the future.

Skip the math entirely

Paste any Unix timestamp — seconds, milliseconds, or otherwise — and get the exact readable date back instantly. Free, private, no sign-up.

Open the converter →

08Frequently asked questions

How do I convert a Unix timestamp to a date manually?

Divide the timestamp by 86,400 (the seconds in a day) to get the number of whole days since 1 January 1970; the remainder is how many seconds into that day it is. Convert the remainder to hours, minutes, and seconds by dividing by 3,600 and then 60, and count the day total forward from 1 January 1970 to land on the calendar date.

How do I convert a Unix timestamp in JavaScript?

Multiply the timestamp by 1,000 and pass it to the Date constructor, since JavaScript's Date expects milliseconds: new Date(ts * 1000). Call toISOString() or toUTCString() on the result to get a readable UTC string.

How do I convert a Unix timestamp in Python?

Use datetime.fromtimestamp(ts, tz=timezone.utc) from the datetime module. Passing tz=timezone.utc explicitly is important, because omitting it converts to the system's local time zone instead.

Why is my converted date wrong by exactly 1,000 times or thousands of years?

That's the classic seconds-versus-milliseconds mismatch: feeding a seconds value into a function that expects milliseconds, or the reverse, throws the result off by a factor of 1,000. Check the digit count of your timestamp before converting.

Does converting a Unix timestamp give me local time or UTC?

It depends on the function. Many date functions default to your system's local time zone unless you explicitly request UTC, so check your language's documentation and pass a UTC or timezone.utc argument when you want the universal value rather than a local one.

Can I convert a Unix timestamp in Excel or Google Sheets?

Yes. With the timestamp in cell A1, the formula =(A1/86400)+DATE(1970,1,1) converts it to a spreadsheet date-time value; format the cell as a date or date-time to display it.

Fletcher Langley

Fletcher Langley

Time & Scheduling Specialist · 24hourto12hour.com

Operations and workforce-systems specialist with 14+ years inside shift-based industries and payroll platforms. Fletcher builds and reviews every tool on the site, and writes its guides so the method is always shown, not just the answer. Read his full profile →

Sources & standards

  1. The Open Group / IEEE Std 1003.1 (POSIX), Base Definitions, §4.16 "Seconds Since the Epoch" — the formal definition the manual conversion method is built on. opengroup.org
  2. MDN Web Docs, Date reference — behavior of JavaScript's Date constructor and formatting methods. developer.mozilla.org
  3. Python documentation, datetime module — behavior of fromtimestamp() and time-zone handling. docs.python.org
  4. Code snippets tested against each language's current documentation; the manual worked example verified by hand. Last reviewed August 2026.