Date.now() and the Intl API. Working examples for every common operation — get current time, convert epoch to date, convert date to epoch, format display, parse, and handle timezones.
JavaScript's `Date.now()` returns milliseconds since the epoch. For seconds, divide and floor.
Math.floor(Date.now() / 1000)
// → 1735689600
Date.now()
// → 1735689600000
// JavaScript doesn't have native μs. Use performance.now() for relative timing
// or multiply ms × 1000 for an approximation.
Date.now() * 1000
The `Date` constructor accepts milliseconds. If you have seconds, multiply by 1000 first.
const date = new Date(1735689600 * 1000);
console.log(date.toISOString()); // 2025-01-01T00:00:00.000Z
const date = new Date(1735689600000);
console.log(date.toISOString());
new Date(1735689600 * 1000).toUTCString();
// → "Wed, 01 Jan 2025 00:00:00 GMT"
new Date(1735689600 * 1000).toISOString();
// → "2025-01-01T00:00:00.000Z"
All Date objects have `.getTime()` (ms) and `.valueOf()`. For seconds, divide.
Math.floor(new Date().getTime() / 1000);
// or the shorter equivalent:
Math.floor(Date.now() / 1000);
Math.floor(new Date("2025-01-01T00:00:00Z").getTime() / 1000);
// → 1735689600
// Be careful — months are 0-indexed in JavaScript!
const ms = Date.UTC(2025, 0, 1, 0, 0, 0); // January 1, 2025 UTC
Math.floor(ms / 1000);
Native browser API for locale-aware, timezone-aware formatting. No library needed.
const ts = 1735689600;
const formatter = new Intl.DateTimeFormat('en-US', {
timeZone: 'America/New_York',
year: 'numeric', month: 'short', day: '2-digit',
hour: '2-digit', minute: '2-digit', second: '2-digit',
hour12: false, timeZoneName: 'short'
});
formatter.format(new Date(ts * 1000));
// → "Dec 31, 2024, 19:00:00 EST"
// Modern browsers (2022+):
Intl.supportedValuesOf('timeZone');
// → ["Africa/Abidjan", "Africa/Accra", ...] (400+ zones)
Intl.DateTimeFormat().resolvedOptions().timeZone;
// → "America/New_York"
Native `Date` parsing accepts ISO 8601 and RFC 2822. For other formats, parse manually.
new Date("2025-01-01T00:00:00Z").getTime();
// Always parseable across browsers
new Date("Wed, 01 Jan 2025 00:00:00 GMT").getTime();
// Also parseable, but slightly slower
// SAFE — parsed as UTC midnight
new Date("2025-01-01").getTime();
// AMBIGUOUS — parsed differently by different browsers
// Avoid: new Date("01/01/2025")
Where JavaScript date handling will trip you up.
// new Date(2025, 0, 1) is January 1
// new Date(2025, 11, 31) is December 31
new Date(2025, 0, 1); // ✓ January
// "2025-01-01" → midnight UTC
// "2025-01-01T00:00" → midnight LOCAL
// Always append Z or an offset:
new Date("2025-01-01T00:00:00Z");
// .getMonth() returns 0-11
// .getDate() returns 1-31
// .getDay() returns 0-6 (day of week!)
const d = new Date();
[d.getMonth(), d.getDate(), d.getDay()];
// Even if your Date was constructed from a local time,
// toISOString() always shows UTC with the Z suffix.
new Date(2025, 0, 1).toISOString();
// → "2024-12-31T..." (if you're west of UTC)
Need to quickly check what a specific timestamp converts to? Use the main converter — paste any value and get every format back.
Working with many timestamps at once? Try the batch converter — paste a list, get a CSV or JSON file back.