JavaScript Timestamp Guide
JavaScript code examples for Unix timestamps. Use Date.now(), new Date(), toISOString(), and convert between epoch milliseconds and dates.
Built by Michael Lip
Frequently Asked Questions
How do I get the current timestamp in JavaScript?
Use Date.now() for milliseconds, or Math.floor(Date.now() / 1000) for seconds. Both are the most efficient approaches with no object allocation.
How do I convert a timestamp to a date in JavaScript?
Use new Date(timestamp). If your timestamp is in seconds, multiply by 1000 first: new Date(1712000000 * 1000). JavaScript Date always works in milliseconds.
How do I format a date in JavaScript?
Use toISOString() for ISO 8601, toLocaleString() for locale-aware formatting, or Intl.DateTimeFormat for full control over timezone, locale, and format options.
Does JavaScript use seconds or milliseconds?
JavaScript uses milliseconds everywhere. Date.now() returns ms, new Date().getTime() returns ms, and the Date constructor expects ms. Divide by 1000 to get seconds.
How do I parse a date string in JavaScript?
Use new Date('2025-04-02T12:00:00Z') for ISO 8601 strings. For other formats, use Date.parse() but be aware that non-ISO formats may behave differently across browsers.
How It Works
This tool runs entirely in your browser using vanilla JavaScript. No data is sent to any server. All conversions and calculations happen locally on your device, ensuring complete privacy.
EpochPilot uses the browser's built-in Intl.DateTimeFormat API and the IANA timezone database provided by your operating system. This means timezone conversions are always accurate, including Daylight Saving Time transitions.
Related Tools
Privacy
Everything runs locally in your browser. No timestamps, dates, or personal data are transmitted to any server. The source code is open on GitHub.
Contact
EpochPilot is built and maintained by Michael Lip. For questions or feedback, email [email protected].