Unix timestamp is one number: the seconds since 00:00:00 UTC on 1 January 1970. If the date it produces looks wrong, the number is almost never the problem. The unit, the timezone, or the size of the box it is stored in is wrong instead.
The most common symptom is a date in January 1970. That means a value in seconds went into a function that expected milliseconds. The fix is one multiplication by 1,000 — but only after you confirm which unit you actually have, because multiplying a value that is already in milliseconds breaks it the other way.
This guide diagnoses the five ways a Unix timestamp conversion goes wrong, with the exact symptom each one produces and the fix in JavaScript, Python, PHP, and Go. Use our Unix timestamp converter to check any value as you read: it auto-detects seconds, milliseconds, microseconds, and nanoseconds, and shows the result in any timezone.
The 30-Second Diagnosis
Match your symptom to the cause before changing any code. Nearly every wrong date falls into one of these six rows, and each one points at a different fix.
| What you see | Most likely cause | Fix |
|---|---|---|
| Date in January 1970 | Seconds fed to a milliseconds function | Multiply by 1,000 |
| "Invalid Date" or NaN | Milliseconds multiplied by 1,000 again | Stop multiplying; check the unit first |
| Right day, wrong by a few hours | Timezone applied twice, or not at all | Render in UTC first, then convert once |
| Off by exactly one day | Date-only string parsed as UTC | Parse with an explicit timezone |
| Off by one hour in spring or autumn | Daylight saving time | Do the maths in UTC, convert at display |
| 13 December 1901, or dates past 2038 fail | 32-bit signed integer overflow | Use a 64-bit integer or DATETIME column |
If none of these rows matches, run the checklist at the end of this article. It isolates the fault to one specific layer: the value, the unit, the rendering, or the storage.
Bug 1: Seconds vs Milliseconds — the ×1000 Mistake
Two conventions compete for the same count since 1970. The Unix and POSIX convention counts seconds: the date +%s command, most database epoch functions, Go's Unix(), and the exp and iat claims in a JWT all use seconds. JavaScript counts milliseconds instead: Date.now() and new Date().getTime() both return milliseconds.
Feed a seconds value to JavaScript's Date and it reads the number as milliseconds, producing a date 53 years too early. The value 1700000000 is 14 November 2023 in seconds — but JavaScript turns it into 20 January 1970:
new Date(1700000000).toISOString()
// 1970-01-20T16:13:20.000Z — wrong
new Date(1700000000 * 1000).toISOString()
// 2023-11-14T22:13:20.000Z — right
The reverse mistake is just as silent. Multiply a value that is already in milliseconds and the result exceeds JavaScript's supported date range, so you get an invalid date instead of a wrong one:
const ms = 1700000000000;
new Date(ms * 1000).getTime(); // NaN — Invalid Date
The same trap exists in other languages, with different defaults. Python's time.time() returns seconds as a float, while datetime.fromtimestamp() also expects seconds. Go exposes every unit explicitly — Unix(), UnixMilli(), UnixMicro() — which is the clearest design of the four. PHP's time() returns seconds, and DateTime::createFromFormat('U', $ts) expects seconds too.
The fix is to know the unit before converting, not to guess from the size of the number. Name the unit in the column or variable — created_at_ms instead of created_at — and convert at exactly one boundary, where the value enters your code.
Bug 2: The Digit-Count Heuristic Breaks on Old Dates
Counting digits is the standard shortcut for telling seconds from milliseconds: today a seconds value has 10 digits and a milliseconds value has 13. The two representations of the same instant always differ by exactly three digits, so the rule feels safe. It is safe for dates after March 1973 — and it fails silently before that.
Milliseconds values before 3 March 1973 have 11 digits or fewer, so a digit-count check classifies them as seconds and multiplies them by 1,000 a second time. A log archive timestamp from 27 September 1971, stored in milliseconds as 54834200000, becomes 18 August 3707. The mirror case — seconds values from the year 5138 onward — is theoretical, but the pre-1973 case is real data: old log archives, birth dates, and master tapes all carry it.
There is a second edge to the same heuristic. A validator written as ^\d{1,16}$ rejects the minus sign, so every date before 1970 is unparsable, not just mis-parsed. Negative timestamps are valid: -1 is one second before the epoch, 31 December 1969 at 23:59:59 UTC.
The fix is to stop guessing from digits. If the producer can tell you the unit, trust it — read it from the field name, the column type, or the API docs. If it cannot, compare the value against the known landmark 1700000000, which is 14 November 2023: if the value is close to that, it is in seconds; if it is close to a thousand times that, it is milliseconds. For dates before 1970, test the negative case explicitly.
Bug 3: The Timezone Is Wrong — Not the Timestamp
A Unix timestamp is one instant in time. It has no timezone at all. When you print it, the computer has to pick one — and the timezone it picks decides what date and time you see. The same value can render as 14 November in London and 15 November in Tokyo, and both readings are right.
The first place the bug enters is storage. A database stores a timestamp as UTC, then a display layer applies a timezone shift before rendering — but the shift is already in the stored value, because the ORM applied it once on the way in. The date shows as three hours ahead, and the timestamp is not wrong: the timezone was applied twice. The fix is to keep every timestamp in UTC from input to database to output, and convert only at the moment of display. That is the whole timezone discipline.
The second place is the date-only trap. A date without a time, like 2026-11-29, has no instant attached, so every system invents one. Some parse it as midnight in your local zone; some as midnight UTC. In JavaScript, new Date('2026-11-29') parses it as midnight UTC, while new Date(2026, 10, 29) parses it as midnight in local time — and those two can be a day apart. If the date shifts by one at a timezone boundary, the parsing of a date-only string is the first suspect. Pin the input to an explicit timezone, or pass a full timestamp instead of a bare date.
The third place is daylight saving time. A calculation that adds 86,400 seconds to a timestamp assumes every day has 24 hours, and the day the clocks change has 23 or 25. The gap shows up as a date that is one hour off, but only in the weeks around the change. The fix is to add days to the calendar date, not seconds to the timestamp — the calendar knows about DST, the counter does not.
When a date is wrong by hours, not days, start by rendering the value in UTC. If it is right in UTC, the value is fine and the timezone handling is the fault — check whether the offset was applied twice, or whether the zone used at render time is the wrong one.
const ts = 1700000000;
console.log(new Date(ts * 1000).toISOString());
// 2023-11-14T22:13:20.000Z — UTC, the reference
console.log(new Date(ts * 1000).toLocaleString('en-US', { timeZone: 'America/New_York' }));
// 11/14/2023, 5:13:20 PM — same instant, different zone
Bug 4: The Integer Overflow Nobody Notices Until 2038
A Unix timestamp is often stored in a 32-bit signed integer, which fits values up to 2,147,483,647. That is 03:14:07 UTC on 19 January 2038, and one second later the count wraps around to 13 December 1901. The bug is silent today: the field stores every current date fine, so the system passes every test — until a user books a date past 2038 and the result is 1901.
The first fix is to change the storage. A 64-bit integer holds the count for about 292 billion years, which is enough for any practical purpose. If the column is DATETIME rather than a timestamp, check the range instead: MySQL's DATETIME covers 1000–9999, while its TIMESTAMP type shares the 2038 limit.
The second fix is to check the whole pipeline, not just the database. A value that survives the database as 64-bit can overflow in a 32-bit field on the way out — a JSON serializer that casts to int32, a C library, or an embedded device. If you are writing a date library, test the value 2147483647 and the value after it, 2147483648, and confirm both come back sane.
How far off is 2038? At the time of writing, the deadline is about eleven years away — close enough that any mortgage, lease, or thirty-year planning horizon already crosses it. The full history of the problem is on Wikipedia's Year 2038 problem page.
Bug 5: The Value Was Fine — the Parser Broke It
Some wrong dates are not a unit or timezone bug at all. The value arrived correctly and a parser destroyed it on the way in. The three parsers that do it most often are the float, the string, and the JSON number.
First, the float. JavaScript's Number loses precision past 2^53, so a nanoseconds timestamp like 1700000000000000000 is rounded when parsed as a float — and the date that comes out is wrong by whole seconds. The fix is to keep nanoseconds as a string or BigInt until you have divided them down to a unit the language can hold exactly.
Second, the string. A timestamp that arrives with a decimal point — 1700000000.123 — is not an integer, and a parser that takes the integer part silently drops the fraction. A timestamp that arrives with a trailing Z or +00:00 is not a timestamp at all, and a parser that strips the suffix can also strip the sign. Keep the raw string until you have identified the unit.
Third, the JSON number. A long in Java is exact, but the same value in a JavaScript Number is not, so a timestamp that crosses a JSON boundary between languages can change in transit. The safe transport is a string, with the unit in the field name — created_at_ms again.
The fastest way to find which parser is at fault is to print the value at every boundary: the API response, the parsed object, the database row, and the rendered output. The first place the number changes is the layer that broke it. Paste the raw value into a free converter at each step and compare: the converter shows the unit it detected, so a change in the detected unit between steps points at the parser.
Which Timestamp Converter Should You Use?
A converter is only useful if it tells you what it did. The best one shows the unit it detected, the timezone it rendered in, and the same instant in both seconds and milliseconds, so you can check its work instead of trusting it. It should also let you type a date and get the timestamp back, because the bug is often in the conversion you did by hand. A unit converter handles the rest of the conversions — currencies, lengths, and weights — but a timestamp converter is the one that has to get the unit right.
For a quick check, use a browser tool that runs locally: nothing you paste leaves your machine, and the answer is instant. For a production system, use the standard library of your language and convert at exactly one boundary — the point where the value enters your code. Keep the raw value in the log alongside the converted one, so the next person to debug it can see both.
Why JWT Expiry and Cookies Get the Same Bug
JWTs carry their expiry as a Unix timestamp in seconds — the exp claim — and the same ×1000 mistake that breaks a displayed date also breaks a login. A token whose exp is in milliseconds reads as an expiry in 1970, so the token is already expired the moment it is issued, and the user is logged out on every request. The reverse — an exp in seconds read as milliseconds — gives a token that expires in the year 5138, which is a security hole rather than a bug. Paste any token into a JWT decoder and check the exp claim against the current epoch before blaming the auth library.
Cookies have the same shape: the Expires attribute is a date string, and a cookie set with a Unix timestamp in the wrong unit expires immediately or never. If a session cookie vanishes on the first request, check the unit before checking the cookie settings.
A Checklist for Any Wrong Date
Work through these in order. Each step isolates one layer, and the first step that fails names the fault.
1. Print the raw value. If it is not a number, the parser is the fault — go to Bug 5.
2. Check the digits. Ten digits means seconds today, thirteen means milliseconds. If the date is before 1973, compare against the landmark instead — see Bug 2.
3. Render in UTC. If the UTC reading is right, the timezone is the fault — see Bug 3.
4. Check the boundaries. If the date is 1901 or 2038, the storage is the fault — see Bug 4.
5. Fix the unit at one boundary, then re-check. If the date is still wrong, the fault is in the code that reads the value, not the value itself.
The whole diagnosis takes under a minute with a timestamp converter open: paste the value, read the unit it detected, and compare the UTC reading against the landmark. Most wrong dates are one of these five bugs, and most of them are the first one.
Frequently Asked Questions
Why does my Unix timestamp show 1970?
Because a value in seconds went into a function that expected milliseconds. JavaScript's Date reads 1700000000 as 1.7 billion milliseconds — about 20 days after the epoch — instead of 1.7 billion seconds. Multiply the value by 1,000 first, or divide Date.now() by 1,000 when comparing the two.
How do I convert seconds to milliseconds?
Multiply by 1,000: 1700000000 seconds is 1700000000000 milliseconds. To go the other way, divide by 1,000 and drop the fraction. Never multiply blindly — check whether the value is already in milliseconds first, or you will get an invalid date.
Why is my timestamp off by a few hours?
The instant is right and the timezone is wrong. A Unix timestamp carries no zone, so the same value renders as a different wall-clock time in every zone. Render it in UTC first: if the UTC reading is correct, your code is applying a timezone twice, or applying the wrong one.
What is the Year 2038 problem?
Systems that store Unix time in a signed 32-bit integer run out of room at 03:14:07 UTC on 19 January 2038, when the counter reaches 2,147,483,647. One second later it wraps to 13 December 1901. The fix is a 64-bit integer, which has room for roughly 292 billion years.
How do I check a timestamp quickly?
Paste it into a converter that auto-detects the unit and lets you pick the timezone. The free timestamp converter on this site detects seconds, milliseconds, microseconds, and nanoseconds, shows the live epoch time, and converts dates back to timestamps. Compare any suspicious value against the landmark 1700000000, which is 14 November 2023, 22:13:20 UTC.
What is the best Unix timestamp converter?
The best one for your job is the one that shows its working: the unit it detected, the timezone it rendered in, and both seconds and milliseconds for the same instant. A browser converter that runs locally is best for a quick check, because nothing you paste leaves your device. For code, use your language's standard library and convert at one boundary.