Seconds and milliseconds
The Date constructor expects milliseconds when passed a number. Multiply Unix seconds by 1,000.
const seconds = 1711972800;
const date = new Date(seconds * 1000);
console.log(date.toISOString());
// 2024-04-01T12:00:00.000Z
const nowMs = Date.now();
const nowSeconds = Math.floor(nowMs / 1000);Parse a date with an explicit UTC offset
const date = new Date('2024-04-01T14:00:00+02:00');
if (Number.isNaN(date.getTime())) {
throw new Error('Invalid date');
}
console.log(date.getTime()); // 1711972800000A date and time without an offset may be interpreted in the browser time zone. Use Z for UTC or an offset such as +02:00. Validating Date is not enough to reject every impossible calendar date: some are normalized.
Display a geographical time zone
const formatter = new Intl.DateTimeFormat('fr-FR', {
dateStyle: 'full',
timeStyle: 'long',
timeZone: 'Europe/Paris'
});
console.log(formatter.format(date));Precision and large values
Date represents instants to the millisecond. Nanosecond timestamps commonly exceed the integer precision of Number: read them as strings, then use BigInt. Converting to Date does not preserve fractions of a millisecond.
Do not determine the unit solely from the number of digits. A short value may represent milliseconds close to 1970.
References
English version published September 26, 2026.