For Developers

Unix Timestamp in PHP

How to get the current timestamp, convert it to a date, and convert a date back to a timestamp in PHP — plus the specific mistake that trips up PHP code more than any other.

time();
date("Y-m-d H:i:s", 1750000000);
strtotime("2025-06-15 12:00:00");

The PHP-specific pitfall

PHP's date() formats a timestamp using the server's configured default timezone unless you pass a DateTimeZone explicitly — which means the exact same timestamp can print a different wall-clock time depending on server configuration you may not control. For anything timezone-sensitive, use the DateTime class with an explicit DateTimeZone rather than the older procedural functions.

Have a timestamp right now?

Paste it into the Timestamp ⇄ Date Converter to check it instantly, in any timezone, without writing any code. Working across several languages on the same project? The full Epoch Time in Programming Languages guide has all of them side by side for quick comparison.

Related

Related tools & reading