Free tools Windows power users keep installed
One-click scans. No signup required.
iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more
For a Unix timestamp measured in seconds, multiply by 1,000 before passing it to JavaScript’s Date constructor: new Date(unixSeconds * 1000). JavaScript numeric date values use milliseconds, so passing seconds directly produces a date near 1970. [MDN: Representing dates & times]
Convert Unix seconds to a JavaScript Date
A common Unix timestamp is the number of seconds elapsed since 1970-01-01 00:00:00 UTC. JavaScript’s numeric Date time value is measured in milliseconds. Multiply a seconds-based timestamp by 1,000:
const unixSeconds = 1_700_000_000;
const date = new Date(unixSeconds * 1000);
console.log(date.toISOString());
// 2023-11-14T22:13:20.000Z
The multiplication converts the unit; it does not shift the instant into another time zone. A Date represents an instant, while formatting methods determine how that instant is displayed.
Check whether the input is seconds or milliseconds
Use the unit specified by the data source or API contract. Seconds need conversion; milliseconds go directly into the constructor:
#1 Best Overall
// Unix timestamp in seconds
const fromSeconds = new Date(unixSeconds * 1000);
// Epoch timestamp already in milliseconds
const fromMilliseconds = new Date(unixMilliseconds);
Do not guess the unit from the number’s size. Make it explicit when the value enters your application, for example with names such as createdAtSeconds or createdAtMilliseconds. A magnitude-based guess can silently misinterpret valid values.
Use new Date(value) for a numeric timestamp. Calling Date(value) without new is different: it returns a string for the current date and time and ignores the supplied argument. [MDN: Date() constructor]
Rank #2
Choose the output format and time zone
Formatting changes the representation, not the instant. Use UTC output when you need a consistent machine-readable value. Use localized output for people, specifying a time zone when the display must follow a particular region.
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstall| Need | Use | Behavior |
|---|---|---|
| Stable UTC text for storage or interchange | date.toISOString() |
Returns an ISO-format string in UTC, ending in Z. [MDN: toISOString()] |
| Display in the environment’s local time zone | date.toString() or date.toLocaleString() |
Uses the runtime’s local zone; the displayed time and calendar date can differ by location. [MDN: toString()] |
| Localized display in a specific region | date.toLocaleString(locale, { timeZone }) |
Formats for the requested locale and applies the chosen time-zone rules. |
For example, to display the same instant in Los Angeles time:
const date = new Date(unixSeconds * 1000);
const display = date.toLocaleString("en-US", {
timeZone: "America/Los_Angeles",
});
Use toISOString() rather than local display methods when a value must be comparable across machines. Use an explicit IANA time-zone identifier such as America/Los_Angeles when the display zone is part of your application’s requirements. [MDN: Date() constructor]
Validate the timestamp and handle invalid dates
A numeric value outside JavaScript’s supported Date range—±8,640,000,000,000,000 milliseconds—or a value that is not a usable number produces an invalid date. Check the resulting time value before formatting it:
Rank #4
const date = new Date(unixSeconds * 1000);
if (Number.isNaN(date.getTime())) {
throw new RangeError("Timestamp is outside the supported Date range");
}
The Date constructor’s documented range is ±8,640,000,000,000,000 milliseconds. [MDN: Date() constructor]
Negative timestamps are valid when they fall within that range; they represent instants before the Unix epoch. Fractional seconds may also be supplied. Whether to round or truncate them depends on the source system’s contract, so do not apply an extra rounding rule unless that contract calls for it.
Best Value
Avoid parsing a number as a date string
If the input is already a numeric timestamp, construct the date directly. Date.parse() is for parsing date strings and is not needed for this conversion:
// Correct for seconds
const date = new Date(timestampSeconds * 1000);
If the displayed date seems to be in 1970, check whether a seconds-based timestamp was passed without multiplying by 1,000. If the time is correct but the clock time or calendar date differs, check whether it is being formatted in the runtime’s local time zone rather than UTC.
Quick Recap
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.

