Unix Timestamps Explained: Seconds, Milliseconds, UTC and IST
What a Unix timestamp is, how to tell seconds from milliseconds, how to convert one to a readable date in UTC or IST, and the time zone mistakes that cause off-by-hours bugs.
What a Unix timestamp is
A Unix timestamp is the number of seconds that have passed since 00:00:00 UTC on 1 January 1970, a moment called the Unix epoch. Because it is a single number, it is easy to store, compare and sort, and it means the same thing in every time zone. That is why databases, APIs, log files and JWT tokens use it so often.
For example, 1700000000 is 14 November 2023, 22:13:20 UTC.
Seconds or milliseconds?
Some systems count seconds and others count milliseconds. Unix tools, many databases and JWT claims such as exp and iat use seconds. JavaScript, Java and many web APIs use milliseconds. The quickest check is the length. A current timestamp in seconds has 10 digits, such as 1700000000, and one in milliseconds has 13 digits, such as 1700000000000.
If a converted date lands in January 1970, you passed seconds where milliseconds were expected. If it lands tens of thousands of years in the future, you passed milliseconds where seconds were expected. The Timestamp Converter treats small numbers as seconds and large numbers as milliseconds, then shows both values.
Converting to a readable date
Paste the number into the converter and it shows the same moment as an ISO 8601 date in UTC, as a UTC string, in your own local time zone, and as a relative phrase such as 3 days ago. You can also go the other way by typing a date such as 2024-05-01T10:30:00Z and reading the Unix value.
In code, JavaScript uses new Date(seconds * 1000) and date.getTime() for milliseconds. Python uses datetime.fromtimestamp(seconds, tz=timezone.utc) and time.time(). On Linux, date -d @1700000000 prints the date.
UTC and IST
India Standard Time is UTC plus 5 hours 30 minutes, with no daylight saving. To get IST from a UTC time, add 5:30. So 10:30 UTC is 16:00 IST. The timestamp itself does not change between the two. Only the way the moment is written changes.
The converter shows the local time using the time zone of your browser, so if your device is set to India it will show IST directly.
Common mistakes
Most timestamp bugs come from time zones and units rather than the number itself.
- Storing local time instead of UTC. Two servers in different zones then disagree about the same event.
- Parsing a date string with no zone, such as 2024-05-01 10:30. Different parsers treat it as local time or as UTC, so the result can shift by hours.
- Mixing seconds and milliseconds between a frontend and a backend.
- Using a 32-bit integer. A signed 32-bit timestamp runs out on 19 January 2038, so use 64-bit values for dates far in the future.
A good habit
Store and transmit times as UTC timestamps or ISO 8601 strings that end in Z, and convert to a local zone only when you show a time to a person. When something looks wrong in a log, paste the raw number into a converter first. It tells you in a few seconds whether the problem is the value, the unit or the zone.
Reference values to recognise
| Timestamp | UTC date and time | Why it matters |
|---|---|---|
| 0 | 1970-01-01 00:00:00 | The epoch itself, and what a missing or zero value turns into |
| 86400 | 1970-01-02 00:00:00 | Exactly one day, which is 24 x 60 x 60 seconds |
| 1000000000 | 2001-09-09 01:46:40 | The first 10 digit billion mark |
| 1700000000 | 2023-11-14 22:13:20 | A round number often used in examples |
| 1735689600 | 2025-01-01 00:00:00 | Start of 2025 in UTC |
| 2147483647 | 2038-01-19 03:14:07 | The largest signed 32-bit value |
If you see a date in January 1970 in a user interface, the code almost certainly received 0, an empty value or a number in the wrong unit.
Worked example: tracing a wrong date
A frontend shows an expiry date of 20 January 1970. The API returned 1700000000. Step one: JavaScript expects milliseconds, so new Date(1700000000) reads the value as 1,700,000,000 milliseconds. That is about 19.7 days after the epoch, which is 1970-01-20 16:13:20 UTC.
Step two: the value has 10 digits, so it is in seconds. Multiply by 1000 first. new Date(1700000000 * 1000) gives 2023-11-14 22:13:20 UTC.
Step three: add 5 hours 30 minutes if you want IST. The same moment is 2023-11-15 03:43:20 in India, which is already the next calendar day. This is why a date can look one day off for a user in India when the code only uses the UTC date.
Working with start of day
A day boundary depends on the zone. Midnight at the start of 1 May 2024 in UTC is 1714521600. Midnight in IST on the same date is 5 hours 30 minutes earlier in absolute time, so it is 1714521600 minus 19800, which is 1714501800. If a report asks for all events on 1 May and uses the wrong boundary, up to 5 and a half hours of events end up on the wrong day.
Decide which zone defines a day for your reports, write it into the query, and use the same boundary everywhere.
Frequently asked questions
- What is the Unix epoch? It is 00:00:00 UTC on 1 January 1970, the moment from which Unix timestamps are counted.
- How do I get the current timestamp? In JavaScript, Math.floor(Date.now() / 1000) gives seconds. In Python, int(time.time()). On Linux, date +%s.
- Do Unix timestamps include leap seconds? No. Each day is treated as exactly 86,400 seconds, so a timestamp does not count leap seconds.
- Can a timestamp be negative? Yes. A negative value is a moment before 1970. For example, -86400 is 31 December 1969.
- What happens in 2038? Systems that store the timestamp in a signed 32-bit integer overflow after 03:14:07 UTC on 19 January 2038. Using 64-bit integers avoids it.