Key takeaways
- A Unix timestamp counts seconds since 1 January 1970 UTC; 13-digit values are usually milliseconds.
- JavaScript, Python, SQL and the shell each convert a timestamp in one line, and a converter such as AyeTab's does it without code.
- A timestamp has no time zone, so ask for UTC when storing dates and convert to local time only for display.
To convert a Unix timestamp to a date, read it as the number of seconds since 00:00:00 UTC on 1 January 1970 and let a converter or one line of code turn that into a calendar date. The quickest route is to paste the number into a free browser tool such as the AyeTab Unix Time Converter, which shows the UTC and local date at once.
Step 1: check whether it is seconds or milliseconds
Count the digits before you do anything else. A current timestamp in seconds has 10 digits, for example 1800000000. In milliseconds it has 13, for example 1800000000000. JavaScript, many REST APIs and most analytics events use milliseconds; Unix tools, PHP and SQL databases mostly use seconds.
If you treat milliseconds as seconds you get a year far in the future. If you do the opposite, you land in January 1970. Either result is a sign the unit is wrong.
Step 2: pick a method
| Where you are | Method | Example for 1800000000 |
|---|---|---|
| Browser | Paste into AyeTab's converter | 2027-01-15T08:00:00.000Z |
| JavaScript | new Date(ts * 1000).toISOString() |
Multiply seconds by 1,000 |
| Python | datetime.fromtimestamp(ts, tz=timezone.utc) |
Import both from datetime |
| PostgreSQL | SELECT TO_TIMESTAMP(1800000000); |
Returns a timestamp with time zone |
| MySQL | SELECT FROM_UNIXTIME(1800000000); |
Uses the session time zone |
| Linux shell | date -u -d @1800000000 |
GNU date; on macOS use date -u -r 1800000000 |
All of these give 08:00 UTC on 15 January 2027 for that value.
Step 3: decide on the time zone
A Unix timestamp has no time zone. It marks one instant, and the time zone only decides how that instant is written. The same value is 08:00 in London in January and 03:00 in New York.
Most mistakes here come from functions that quietly use the machine's local zone. Python's fromtimestamp without a tz argument returns local time, and MySQL's FROM_UNIXTIME follows the session setting. Ask for UTC explicitly when you store or compare dates, and convert to local time only for display.
Using a converter instead of code
For one value, a converter is faster than opening a terminal. In AyeTab you type into the field labelled "Timestamp or date" and get six cards: seconds, milliseconds, ISO 8601 in UTC, your local time with its zone name, a UTC date and a relative time such as "3 days ago". A 13-digit input is treated as milliseconds automatically. Click a card to copy its value.
It also works the other way round. Type a date string and the cards show its timestamp, which answers the reverse question of how to turn a date into Unix time.
AyeTab runs the conversion in your browser. Nothing is uploaded and there is no account, which matters when the timestamp comes from a production log. The tools are free on app.ayetab.com, and the AyeTab Chrome extension puts them on your new tab page.
Going the other way: date to timestamp
The reverse question comes up just as often, for example when you build an API query for "everything since Monday". Write the date in ISO 8601 with an explicit zone, such as 2027-01-15T08:00:00Z, so nothing guesses the zone for you. Then let the tool count the seconds. In JavaScript, Date.parse() returns milliseconds, so divide by 1,000 and round down. In Python, datetime.timestamp() returns seconds as a float. In AyeTab, paste the same string and read the seconds card.
Common problems
- The date is in 1970. You passed seconds to a function that expects milliseconds, such as JavaScript's Date, or the value was empty and became zero.
- The year is far in the future. You passed milliseconds as seconds. Divide by 1,000.
- The hour is off by a few. One side used UTC and the other local time.
- A value near 2147483647 breaks. Systems that store time as a signed 32-bit integer run out at 03:14:07 UTC on 19 January 2038.
If you need microsecond or nanosecond values (16 or 19 digits), epochconverter.com supports those, while AyeTab sticks to seconds and milliseconds.
Frequently asked questions
How do I know if a timestamp is in seconds or milliseconds?
Count the digits. Current timestamps have 10 digits in seconds and 13 in milliseconds.
Why does my converted date show 1970?
Usually a function that expects milliseconds, such as JavaScript's Date, got seconds. An empty value that became zero does the same. Check the unit first.
Can I convert a date back to a Unix timestamp?
Yes. Type the date into the AyeTab Unix Time Converter, or use Date.parse in JavaScript (which returns milliseconds) or datetime.timestamp() in Python.
Sources
- Unix Time ConverterAyeTab
- AyeTabAyeTab
- Epoch Converterepochconverter.com
- datetime: basic date and time typesPython Software Foundation
- DateMDN Web Docs