PHP Timestamp Guide
PHP code examples for Unix timestamps. Use time(), strtotime(), date(), DateTime class, and convert between epoch and formatted dates.
Built by Michael Lip
Frequently Asked Questions
How do I get the current timestamp in PHP?
Use time() for the current epoch in seconds. For milliseconds, use (int)(microtime(true) * 1000). The time() function is the most common approach.
How do I convert a timestamp to a date in PHP?
Use date('Y-m-d H:i:s', 1712000000) to format an epoch as a readable string. The date() function accepts a format string and an optional timestamp.
How do I convert a date string to a timestamp in PHP?
Use strtotime('2025-04-02 12:00:00') to parse a date string into an epoch. strtotime() understands many formats including relative dates like '+1 week' and 'next Monday'.
What is the difference between time() and strtotime()?
time() returns the current epoch timestamp. strtotime() parses a date string into a timestamp. Use time() for 'now' and strtotime() for converting date strings.
How do I use the DateTime class in PHP?
Use new DateTime() for current time, or new DateTime('@1712000000') from an epoch. Format with $dt->format('Y-m-d H:i:s'). DateTime supports timezone handling and date arithmetic.
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].