Convert a Unix timestamp to a date, and a date to a timestamp
Published · Updated 3 min read
A Unix timestamp is a number that counts the time elapsed since 1 January 1970 at midnight, in universal time. You meet it in databases, program logs and site interfaces. Two questions decide the date you get: the unit of the number, and the time zone in which you read the result.
A reference value
Convert Unix timestamp gives three readings of the same instant. For 1700000000, with a browser set to Paris time:
| Reading | Result |
|---|---|
| UTC date | Tue, 14 Nov 2023 22:13:20 GMT |
| Local date | 14 November 2023 at 23:13:20 UTC+1 |
| ISO | 2023-11-14T22:13:20.000Z |
Local time follows the browser's time zone: one hour more in Paris in winter. The same timestamp is a single instant, read in two time zones.
The unit is recognized from the number of digits
The default setting recognizes the unit by the length of the number. The three following values designate the same instant, to within precision.
| Number | Digits | Unit recognized | Instant obtained |
|---|---|---|---|
| 1700000000 | 10 | Seconds | 14 Nov 2023, 22:13:20 UTC |
| 1700000000000 | 13 | Milliseconds | 14 Nov 2023, 22:13:20 UTC |
| 1700000000123456 | 16 | Microseconds | 14 Nov 2023, 22:13:20.123 UTC |
The rule: up to 11 digits, seconds; from 12 to 14, milliseconds; 15 and 16, microseconds. The "milliseconds" setting forces that unit.
The trap of the rule
Since the unit is deduced from the length, an ambiguous value is read one way only: 10000000000 (11 digits) gives 20 November 2286, and 100000000000 (12 digits) 3 March 1973. A timestamp in milliseconds earlier than March 1973 has 11 digits or fewer, and would be read as seconds: then force the "milliseconds" setting.
Values before 1970 and the 2038 limit
A negative number designates an instant before 1970: −1 gives 31 December 1969 at 23:59:59 UTC, and 0 gives 1 January 1970 at midnight.
The number 2147483647 is the largest that a signed 32-bit integer can hold: it gives 19 January 2038 at 03:14:07 UTC. The next number, 2147483648, gives 03:14:08. The tool carries on without limit, but a system that stores time on 32 bits cannot: this is the "year 2038 bug".
Convert a date to a timestamp
Enter a date instead of a number: the tool gives the timestamp in seconds and in milliseconds.
| Input | Timestamp in seconds | Reading |
|---|---|---|
| 2026-01-01 | 1767225600 | Midnight in universal time, no time zone given |
| 2026-01-01T10:30:00+01:00 | 1767259800 | 10:30 in Paris, that is 09:30 in universal time |
| 2024-02-29 | 1709164800 | Leap year accepted |
A date without a time zone is read in universal time, not local time: the tool reminds you in the result. A date that does not exist, such as 30 February 2026, is refused with a message.
Common mistakes
- Reading milliseconds as seconds: the date lands thousands of years too far.
- Forgetting the time zone: a date read as local then sent as universal shifts by one or more hours.
- Writing a date without a time zone while thinking of local time, when it will be read in universal time.
To count the days between two dates, see Count the days between two dates.
For which cases
A program log, a database, an online service response or an exported file: the number is hard to read, the date reads at once.
Check a conversion
- Read the UTC line again, which does not depend on your device.
- Check the unit announced in the first line of the result.
- Convert the resulting date back: you must get the starting number again.
Frequently asked questions
- What is a Unix timestamp?
- The number of seconds elapsed since 1 January 1970 at midnight, in universal time.
- How do you know whether a number is in seconds or milliseconds?
- The tool deduces it from the number of digits: up to 11 digits, seconds; from 12 to 14, milliseconds; 15 and 16, microseconds.
- What happens in 2038?
- The number 2147483647, the largest signed 32-bit integer, corresponds to 19 January 2038. A system that stores time on 32 bits cannot go further.
- Which time zone is used for a date without a time zone?
- Universal time, not local time. The tool reminds you in the result.
