If a JavaScript date unexpectedly shows a time in 1970, check whether a timestamp in seconds was passed to code expecting milliseconds. JavaScript interprets numeric Date inputs as milliseconds since the Unix epoch, so a seconds value is treated as a much smaller interval after January 1, 1970. Confirm the unit in the source documentation before converting.
Why a seconds timestamp becomes a date in 1970
The Unix epoch is midnight UTC on January 1, 1970. Unix time is usually expressed as the number of seconds since that instant, while a JavaScript Date numeric value represents milliseconds since the epoch. MDN describes a JavaScript date as milliseconds elapsed since the epoch (MDN: Date); its Unix time glossary describes Unix time as usually counting seconds (MDN: Unix time).
As an Amazon Associate I earn from qualifying purchases.
That difference is a factor of 1,000. Passing a seconds value directly to new Date() makes JavaScript interpret the number as milliseconds, placing the result close to the epoch rather than at the intended modern date.
Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchPC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Check the timestamp unit before converting
- Inspect the raw value and type. Find the exact value arriving from the API, database, or serialized payload before formatting it.
- Check the producer’s contract. Look up the field documentation for its epoch and precision: seconds, milliseconds, microseconds, or another representation. The phrase “Unix timestamp” by itself may not settle the unit.
- Convert only when needed. For seconds, multiply by 1,000 before passing the value to a JavaScript
Date. For milliseconds, pass it through unchanged. - Check for double scaling. Multiplying a value already in milliseconds by 1,000 can push it far beyond the intended date or outside the range JavaScript can represent.
- Check the display timezone. If the instant is right but the clock time or calendar date differs, inspect how it is formatted; local timezone display can shift the visible result.
Seconds to JavaScript milliseconds
const seconds = 1_700_000_000;
const date = new Date(seconds * 1000);
The number is an illustrative example. The correct operation depends on the documented unit of your own input.
Milliseconds to a JavaScript date
const milliseconds = 1_700_000_000_000;
const date = new Date(milliseconds);
JavaScript’s Date.now() also returns milliseconds since the epoch. To convert that value to whole seconds, divide by 1,000; use Math.floor() when you specifically need the count of fully elapsed seconds (MDN: Date.now()).
Distinguish a timezone display from a wrong instant
A JavaScript date represents an instant, but common component methods such as getHours() and getDate() use the host computer’s local timezone. That can change the displayed clock time or move the calendar date across midnight without changing the underlying instant. If you need a consistent UTC display, use UTC getters or an explicit timezone formatter. MDN documents the local-time behavior of date components (MDN: Date).
Rank #2
- The Unix Programming Environment (Prentice-Hall Software Series)
- Product Type: ABIS_BOOK
- Pearson
A timezone difference can explain an offset of hours or a neighboring calendar date; it cannot turn a near-epoch instant into a modern one. Check the unit and origin first when the result is in 1970.
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →When scaling does not fix the date
- Verify the epoch as well as the unit. Not every timestamp system starts at the Unix epoch. Establish both the origin and precision from the producer’s documentation before converting.
- Check for zero or missing data. A timestamp of zero intentionally represents the epoch. Some applications also use zero to mean “not set,” so consult the application’s own semantics before treating it as an event time.
- Check parsing and formatting. If producer and consumer agree on origin and unit, investigate whether the value is missing, parsed incorrectly, or displayed in a timezone you did not expect.
Quick conversion reference
| Input representation | JavaScript Date expects | What to do |
|---|---|---|
| Seconds since the Unix epoch | Milliseconds since the epoch | Multiply by 1,000 |
| Milliseconds since the Unix epoch | Milliseconds since the epoch | Pass through unchanged |
| JavaScript milliseconds converted to whole seconds | Seconds since the epoch | Divide by 1,000; use Math.floor() for fully elapsed whole seconds |
Do not use digit count as proof of a unit. Modern epoch timestamps are often around 10 digits in seconds and 13 in milliseconds, but that is only a range-dependent clue; other units, epochs, and encodings exist.
Quick Recap
Rank #4
Rank #3
- Used Book in Good Condition
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




