time(), date() and gmdate()
Convert a PHP Unix timestamp to a date
PHP returns seconds directly from `time()`, no division needed. Format them with `date()` (server-local) or `gmdate()` (UTC).
Parse ISO 8601 strings with `strtotime()`, which understands most common formats including `2025-08-02T12:00:00Z`.
Current Unix timestamp (seconds)
$now = time();
echo $now; // 1,754,136,000 Convert epoch seconds → human-readable (UTC)
echo gmdate('Y-m-d H:i:s', 1754136000); // 2025-08-02 12:00:00
// or server-local time:
echo date('Y-m-d H:i:s', 1754136000); Convert ISO 8601 → epoch seconds
$ts = strtotime('2025-08-02T12:00:00Z');
echo $ts; // 1754136000 Real-world use cases for PHP
- Writing an expiry check for password-reset links stored as epoch seconds in a MySQL table.
- Converting a WordPress or Laravel created_at string into a timestamp for a REST API response.
- Scheduling cron-style jobs by comparing the current time() against stored epoch deadlines.
| Unix timestamp (seconds) | ISO 8601 (UTC) |
|---|---|
| 0 | 1970-01-01T00:00:00.000Z |
| 946,684,800 | 2000-01-01T00:00:00.000Z |
| 1,754,136,000 | 2025-08-02T12:00:00.000Z |
| 2,147,483,647 | 2038-01-19T03:14:07.000Z |
| 2,524,608,000 | 2050-01-01T00:00:00.000Z |
These are the same fixed timestamps used in the PHP examples above — every conversion returns one of these values.
Frequently asked questions
How do I get the current Unix timestamp in PHP?
Just call time() — it returns the current epoch in seconds directly, with no division or conversion needed. For milliseconds use intdiv((int)(microtime(true) * 1000), 1) or round(microtime(true) * 1000).
How do I convert an epoch timestamp to a date in PHP?
Use gmdate('Y-m-d H:i:s', 1754136000) for UTC or date() for the server timezone. The uppercase g in gmdate means "GMT/UTC"; the lowercase d is what you want for local time.
How do I parse an ISO 8601 string to a timestamp in PHP?
strtotime() understands ISO 8601 strings like '2025-08-02T12:00:00Z' and returns epoch seconds. For date-only strings like '2025-08-02' it returns midnight UTC by default.
Epoch to human date in PHP
Try it live — convert any timestamp in PHP-friendly format.
Seconds or milliseconds — the unit is auto-detected. Example: 1735689600
UTC ISO 8601
–
Local — auto
–
RFC 2822 / GMT
–
Seconds value
–
Relative time
–
Other programming languages
Copy-paste epoch conversion snippets in your favorite stack
More timestamp guides
Example values used above: epoch seconds = 1,754,136,000 · ISO 8601 = 2025-08-02T12:00:00.000Z. Curious how the numbers work? See the Unix epoch time FAQ, or view the current epoch time in any timezone.