PHP gmdate() Function

Quick summary: The PHP gmdate() function formats a date/time in UTC (GMT) instead of local timezone.

PHP gmdate() Syntax

gmdate(string $format, ?int $timestamp = null): string
PHP

PHP gmdate() Basic examples

echo gmdate('Y-m-d H:i');
PHP
Output:
2026-02-08 10:34

Formats the current UTC date and time.

PHP gmdate() Real-world usage

$timestamp = time();
echo gmdate('c', $timestamp);
PHP
Output:
2026-02-08T10:34:00+00:00

Outputs ISO-8601 timestamps in UTC for APIs.

PHP gmdate() Edge cases

echo gmdate('Y-m-d', 0);
PHP
Output:
1970-01-01

Formats the Unix epoch start in UTC.

PHP gmdate() Common mistakes

Using date instead of gmdate for UTC

date() uses local timezone.

Incorrect
date('c');
Correct
gmdate('c');

Use gmdate for timezone-independent output.

PHP gmdate() Frequently Asked Questions

What does gmdate() do?

Formats a timestamp in GMT/UTC.

Difference from date()?

gmdate ignores local timezone.

Use case?

Standardized timestamps.

Requires timestamp?

Optional.

Common mistake?

Expecting local time.

Performance?

Fast.

Safe?

Yes.

Returns string?

Yes.

Alternative?

date().

Used in APIs?

Yes.

Timezone independent?

Yes.

Best practice?

Use for UTC output.

PHP gmdate() Related PHP Functions