Halloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk3 min

Why a Date Lands in 1970: Check Unix Timestamp Units

When a JavaScript date shows 1970, check whether a Unix timestamp in seconds was passed where milliseconds are expected. Verify the unit and epoch before converting.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Check the timestamp unit before converting

  1. Inspect the raw value and type. Find the exact value arriving from the API, database, or serialized payload before formatting it.
  2. 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.
  3. Convert only when needed. For seconds, multiply by 1,000 before passing the value to a JavaScript Date. For milliseconds, pass it through unchanged.
  4. 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.
  5. 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
Sale
The Unix Programming Environment (Prentice-Hall Software Series)
  • 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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

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.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

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

SaleBestseller No. 2
The Unix Programming Environment (Prentice-Hall Software Series)
The Unix Programming Environment (Prentice-Hall Software Series)
The Unix Programming Environment (Prentice-Hall Software Series); Product Type: ABIS_BOOK; Pearson
$70.65
SaleBestseller No. 3
SaleBestseller No. 4

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.