Unix timestamps explained: seconds, milliseconds, time zones and the year 2038
AdvertisementOpen a database, an API response or a log file and you will often find a date written as a ten-digit number such as 1700000000. It is not a code or an ID. It is a Unix timestamp: the number of seconds that have passed since a fixed moment in 1970. Computers love this format and people cannot read it. The free Unix Timestamp Converter turns a timestamp into a date you can read, in ISO format, in UTC and in your own time zone, and turns a date back into a timestamp. This guide explains how it works so that you can read and debug times with confidence.
The definition
A Unix timestamp counts the seconds since 1 January 1970, 00:00:00 UTC, a moment called the Unix epoch. The count at the epoch is 0, and it grows by one every second. A few reference points that you can check in the tool:
| Timestamp | Date and time (UTC) |
|---|---|
0 |
1970-01-01 00:00:00 |
1000000000 |
2001-09-09 01:46:40 |
1700000000 |
2023-11-14 22:13:20 |
1767225600 |
2026-01-01 00:00:00 |
1893456000 |
2030-01-01 00:00:00 |
2147483647 |
2038-01-19 03:14:07 |
Why a single number? It is compact, it has no format to parse and no language, it sorts correctly as a plain number, and subtracting two timestamps gives the time between them in seconds. Compare that with the text 23/10/2026, which means 23 October in India and might mean nothing at all in a country that writes the month first.
Seconds or milliseconds
This is the most common source of confusion. Two sizes are in use:
- Seconds, usually 10 digits today:
1700000000. Used by Unix systems, PHP'stime(), Python'stime.time()(as a decimal), MySQL'sUNIX_TIMESTAMP()and many APIs. - Milliseconds, 13 digits:
1700000000000. Used by JavaScript'sDate.now()and by Java and many mobile systems.
The converter looks at the size of the number you enter. A value with an absolute size of 100 billion or more is treated as milliseconds; anything smaller is treated as seconds. Both of these show the same instant, 14 November 2023 at 22:13:20 UTC.
If the result is wrong, you have the wrong unit. The signs are easy to remember:
- A date in January 1970 means a milliseconds value was read as seconds by something that expected the other way: for example
1700000000fed into JavaScript'snew Date()gives 20 January 1970. - A date tens of thousands of years in the future means a seconds value was multiplied again.
Time zones
A timestamp has no time zone. It is the same instant for the whole planet. A time zone only matters when you display it. The instant 1700000000 is:
- 22:13:20 on 14 November in UTC,
- 03:43:20 on 15 November in India (UTC+5:30),
- 17:13:20 on 14 November in New York (UTC-5 in winter).
The tool shows the result in UTC, in the ISO 8601 format and in the time zone set in your browser, with a "relative" line like "3 years ago". The ISO format 2023-11-14T22:13:20.000Z is the one to use when you write times in text, JSON or logs. The T separates date and time, and the Z means UTC.
This is why good systems store UTC and convert to the user's zone only at the screen. Storing local times is a classic bug source: during the hour when daylight saving time ends, the same local time happens twice, and in the hour when it begins, one local time does not exist at all. A timestamp avoids both problems.
Using the converter
- Open the Unix Timestamp Converter.
- Enter a timestamp in seconds or milliseconds, or press Now to fill in the current time.
- Read the ISO date, the UTC date, your local time and the relative time.
- To go the other way, choose a date and time in the picker. The tool shows the matching timestamp in seconds and in milliseconds.
The picker uses your local time zone, so choosing "1 January 2026, 00:00" in India gives a timestamp that is 5 hours 30 minutes earlier than the one for the same clock time in UTC. If you need midnight UTC, convert it yourself or use the value in the table above.
Where timestamps appear
- Databases. Columns that hold a date as an integer, or the result of
UNIX_TIMESTAMP(). The MySQL course covers the date functions in Date and time functions. - APIs and JSON. Fields such as
created_at,exp(expiry of a login token) oriat(when it was issued) are very often timestamps. Format the response first with the JSON Formatter to read it. - Log files and monitoring. Each line starts with the time of the event.
- Cookies and caches. Expiry times are often stored as timestamps.
- File systems. A file's modified time is a timestamp underneath.
In PHP you work with them using time(), strtotime() and date(), described in the dates and times lesson. Plenty of bugs come from mixing server time with user time, so decide early where the conversion happens.
Leap seconds, negative values and limits
Unix time ignores leap seconds: every day is treated as exactly 86,400 seconds long. That makes arithmetic simple, at the cost of a small difference from astronomical time that clocks quietly absorb.
Negative timestamps are valid and count back from 1970. -86400 is 31 December 1969. The converter accepts them.
The year 2038 problem
Many older systems stored the timestamp as a signed 32-bit integer. The largest value such a number can hold is 2,147,483,647, which is 2038-01-19 03:14:07 UTC. One second later the number overflows and wraps around to a large negative value, which a system would read as December 1901. Software that still uses 32-bit times, mostly old embedded devices and legacy databases, will misbehave then. Modern systems use 64-bit values, which last for hundreds of billions of years, and are not affected. If you design a new table, make sure a time column is not a 32-bit integer if it may need to hold dates after 2038, such as the end of a 30-year contract.
Common mistakes
- Using the wrong unit, seconds against milliseconds.
- Showing UTC to users without conversion, or converting twice.
- Storing local times without the zone.
- Comparing a timestamp to a formatted string. Convert both to the same form first.
- Treating the timestamp as a string of digits and slicing it, which breaks when the length changes.
- Assuming a day is always 24 hours when working with local times and daylight saving.
Related tools
If you need a unique ID to go with a record's timestamp, the UUID Generator makes one. To work out the exact gap between two calendar dates in years, months and days, use the Age & Date Difference Calculator. And if you want to compute how far a date is from today in a loan or deposit context, the EMI Calculator and FD & RD Calculator work with months.
Quick answers
What is epoch time? Another name for a Unix timestamp: the seconds since 1 January 1970 UTC.
How do I get the current timestamp? Press Now in the tool. In JavaScript use Math.floor(Date.now() / 1000) for seconds, in PHP time(), and in MySQL UNIX_TIMESTAMP().
Why does my date show 1970? The value is probably in milliseconds but was read as seconds, or the field is empty and treated as 0.
Is a timestamp the same everywhere? Yes. Only the display depends on the time zone.
Does the tool send my data anywhere? No. The conversion runs in your browser.