PHP gmdate() Function
Example
Format a GMT/UTC date and time and return the formatted date strings:
<?php
// Prints the day
echo gmdate("l") . "<br>";
// Prints the day, date, month, year, time, AM or PM
echo gmdate("l jS \of F Y h:i:s A");
?>
Try it Yourself »
Definition and Usage
The gmdate() function formats a GMT/UTC date and time, and returns the formatted date string.
Syntax
gmdate(format, timestamp)
Parameter Values
| Parameter | Description |
|---|---|
| format | Required. Specifies the format of the outputted date string. The following characters can be used:
and the following predefined constants can also be used (available since PHP 5.1.0):
|
| timestamp | Optional. Specifies an integer Unix timestamp. Default is the current local time (time()) |
Technical Details
| Return Value: | Returns a formatted date string on success. FALSE on failure + an E_WARNING |
|---|---|
| PHP Version: | 4+ |
| PHP Changelog: | PHP 5.1: Valid range of timestamp is now from Fri, 13 Dec 1901 20:45:54 GMT to Tue, 19 Jan 2038 03:14:07 GMT. Before version 5.1 timestamp was limited from 01-01-1970 to 19-01-2038 on some systems (e.g. Windows). PHP 5.1.1: Added the constants of standard date/time formats that can be used to specify the format parameter |
❮ PHP Date/Time Reference