How do I get current epoch time in JavaScript?
Use Date.now() for milliseconds and Math.floor(Date.now() / 1000) for seconds. Both values are Unix epoch time in UTC.
If you searched for current epoch time, JavaScript gives you the value in one line. In 2026, the fastest path is still Date.now(), which returns a 13-digit Unix timestamp in milliseconds. For APIs that expect 10-digit seconds, convert with Math.floor(Date.now() / 1000) before sending.
Keep timestamps as UTC integers through storage and transport. Convert to local time only in the UI layer. This avoids daylight-saving and timezone drift issues when frontend, backend, and database services are in different regions.
Current epoch milliseconds
const epochMs = Date.now();
Current epoch seconds
const epochSeconds = Math.floor(Date.now() / 1000);
Normalize unknown unit
const normalizeToSeconds = (value) => String(value).length === 13 ? Math.floor(value / 1000) : value;
For a general reference, see current epoch time in 2026. Need 13-digit values and conversions? Open current millis. For endpoint integration examples, check current epoch API patterns.
Need a two-way converter while debugging payloads? Open the main epoch converter tool.
Validating timestamp fields in payload strings? Use Regex Tester & Debugger.
Use Date.now() for milliseconds and Math.floor(Date.now() / 1000) for seconds. Both values are Unix epoch time in UTC.
Send the unit your API contract expects. Most backend APIs expect seconds, while browser analytics and event streams often use milliseconds.
The most common bug is unit mismatch. Passing milliseconds into code that expects seconds can shift dates by decades.
No. The numeric Unix value is timezone-neutral. Timezone matters only when formatting to human-readable date strings.