How to Convert a Unix Timestamp to a Date (and Back)
You found a number like 1678886400 in a database, an API response, a log file, or a JWT — and you need to know what date it actually means. That number is a Unix timestamp: a count of seconds since a fixed moment in 1970. On its own it is unreadable, but converting it back into a normal date takes seconds once you know the one trick that trips almost everyone up.
This guide shows you how to convert a Unix timestamp to a date, how to convert a date back into a timestamp, and how to avoid the single most common mistake — mixing up seconds and milliseconds. You can do the whole thing right now with the free Timestamp Converter, which runs entirely in your browser so nothing you paste is ever uploaded.
What Is a Unix Timestamp?
A Unix timestamp (also called epoch time or POSIX time) is the number of seconds that have elapsed since 00:00:00 UTC on January 1, 1970 — a moment programmers call "the epoch." So 1678886400 means "1,678,886,400 seconds after the start of 1970," which works out to March 15, 2023.
Why store dates this way? Because a single integer is unambiguous, easy to sort, easy to do math on, and free of timezone or formatting confusion. Every system can agree on the number, then display it in whatever local format the user needs. That is why you see Unix timestamps everywhere: SQL databases, REST APIs, server logs, cookies, and the iat/exp fields inside JWT tokens.
One thing it is not: a date in any particular timezone. The epoch is anchored to UTC. The timestamp itself carries no timezone — the timezone only appears when you convert it for display.
The Seconds vs Milliseconds Trap (Read This First)
This is the mistake that wastes more time than any other, so handle it before you convert anything.
Unix timestamps come in two common lengths:
- Seconds — about 10 digits today (e.g.
1678886400). This is the classic Unix timestamp used by most databases, APIs, and command-line tools. - Milliseconds — about 13 digits today (e.g.
1678886400000). JavaScript, Java, and many front-end systems use this. It is just the seconds value with three extra digits on the end.
If you convert a value using the wrong unit, your date will be wildly off — usually landing in January 1970 (if you treated milliseconds as seconds) or thousands of years in the future (if you treated seconds as milliseconds). The fix is simple: count the digits. 10 digits = seconds, 13 digits = milliseconds.
| Value | Digits | Unit | Resolves to |
|---|---|---|---|
1678886400 | 10 | Seconds | Mar 15, 2023 |
1678886400000 | 13 | Milliseconds | Mar 15, 2023 |
Important — how FileNaut's converter expects input: the Timestamp Converter reads the timestamp field in milliseconds. If you have a standard 10-digit timestamp in seconds, multiply it by 1000 (in practice, add three zeros) before pasting — so 1678886400 becomes 1678886400000. Paste the 13-digit value and you'll get the correct date.
How to Convert a Unix Timestamp to a Date
Using the free Timestamp Converter:
- Open the Timestamp Converter and make sure the Timestamp to Date tab is selected.
- Check your number's length. If it's a 10-digit (seconds) timestamp, add three zeros to turn it into milliseconds — e.g.
1678886400→1678886400000. If it's already 13 digits, leave it as-is. - Paste the value into the Timestamp (ms) field.
- Click Convert. The readable date and time appear instantly, shown in your computer's local timezone.
- Click the copy icon to grab the result.
Because everything runs in your browser, you can safely convert timestamps pulled from production logs or private databases — the data never leaves your device.
How to Convert a Date Back to a Unix Timestamp
Sometimes you need the reverse: you have a calendar date and you want the timestamp to store or query against.
- Open the Timestamp Converter and select the Date to Timestamp tab.
- Pick the date and enter the time (hours, minutes, seconds).
- Click Convert. You'll get the Unix timestamp in milliseconds (13 digits).
- If your system needs the value in seconds, drop the last three digits (divide by 1000). For example,
1678886400000ms →1678886400seconds.
The date and time you enter are interpreted in your local timezone, so the resulting timestamp corresponds to that local moment.
Converting Timestamps in Code (Quick Reference)
If you'd rather convert in your own code, here are the one-liners. Remember the unit difference: most languages default to one or the other.
// JavaScript — uses milliseconds
new Date(1678886400 * 1000) // timestamp (seconds) -> Date
Math.floor(Date.now() / 1000) // now -> timestamp (seconds)
# Python — uses seconds
import datetime
datetime.datetime.utcfromtimestamp(1678886400) # -> 2023-03-15 00:00:00
int(datetime.datetime.now().timestamp()) # now -> seconds
-- SQL (PostgreSQL) — uses seconds
SELECT to_timestamp(1678886400);
# Command line (Linux/macOS)
date -d @1678886400 # GNU/Linux
date -r 1678886400 # macOS / BSD
Notice JavaScript multiplies by 1000 because it works in milliseconds, while Python, SQL, and date expect seconds. That single difference is the seconds-vs-milliseconds trap in action.
A Note on Timezones
The timestamp itself is always anchored to UTC, but a readable date only makes sense in some timezone. Tools differ in what they show:
- FileNaut's converter displays the result in your browser's local timezone — convenient for "what time was this for me?"
- Many backend tools (like Python's
utcfromtimestampor SQL'sto_timestamp) show UTC.
So the same timestamp can read as "March 15, 2023, 5:00 PM" on one tool and "March 16, 2023, 12:00 AM" on another — they're the same instant, just shown in different timezones. If a converted date looks a few hours off from what you expected, a timezone difference is almost always the reason, not a conversion error.
Tips
- Count digits before converting. 10 = seconds, 13 = milliseconds. This one habit prevents the most common error.
- Sanity-check the year. A modern timestamp should land in the 2020s. If you get 1970 or the year 50,000, you used the wrong unit.
- Working with JWTs? The
iat(issued-at) andexp(expiry) claims are Unix timestamps in seconds. Decode the token with the JWT Decoder, then convert those numbers to see when a token was issued or expires. - Reading API responses? Paste the whole payload into the JSON Formatter first to find the timestamp fields, then convert them.
- Negative timestamps are valid — they represent dates before 1970.
Frequently Asked Questions
What is a Unix timestamp? ▼
How do I convert a Unix timestamp to a date? ▼
Why did my timestamp convert to a date in 1970? ▼
What's the difference between seconds and milliseconds timestamps? ▼
How do I convert a date back into a Unix timestamp? ▼
What timezone does the converted date use? ▼
Is it safe to convert timestamps from private data? ▼
Ready to try it?
Use the tool right now — free, no signup, no upload.