Easy Tutorial
❮ Php Ref Misc Func Filesystem Linkinfo ❯

PHP gmdate() Function

PHP Date/Time Reference Manual

Example

Formats the GMT/UTC date and time and returns a formatted date string:


Definition and Usage

The gmdate() function formats the GMT/UTC date and time and returns a formatted date string.

Syntax

Parameter Description
format Required. Specifies the format of the output date string. The following characters can be used: d - Day of the month (01 to 31)<br> D - Text representation of the day of the week (three letters)<br> j - Day of the month without leading zeros (1 to 31)<br> l ('L'的小写形式) - Full text representation of the day of the week<br> N - ISO-8601 numeric representation of the day of the week (1 for Monday, 7 for Sunday)<br> S - English ordinal suffix for the day of the month (2 characters: st, nd, rd, or th. Works with j)<br> w - Numeric representation of the day of the week (0 for Sunday, 6 for Saturday)<br> z - Day of the year (0 to 365)<br> W - ISO-8601 week number of the year (weeks start on Monday)<br> F - Full text representation of the month (January to December)<br> m - Numeric representation of the month (01 to 12)<br> M - Short text representation of the month (three letters)<br> n - Numeric representation of the month without leading zeros (1 to 12)<br> t - Number of days in the given month<br> L - Whether it's a leap year (1 if it is, otherwise 0)<br> o - ISO-8601 year number<br> Y - Four-digit representation of the year<br> y - Two-digit representation of the year<br> a - Lowercase ante meridiem and post meridiem (am or pm)<br> A - Uppercase ante meridiem and post meridiem (AM or PM)<br> B - Swatch Internet Time (000 to 999)<br> g - 12-hour format without leading zeros (1 to 12)<br> G - 24-hour format without leading zeros (0 to 23)<br> h - 12-hour format with leading zeros (01 to 12)<br> H - 24-hour format with leading zeros (00 to 23)<br> i - Minutes with leading zeros (00 to 59)<br> s - Seconds with leading zeros (00 to 59)<br> u - Microseconds (added in PHP 5.2.2)<br> e - Timezone identifier (e.g., UTC, GMT, Atlantic/Azores)<br> I (capital i) - Whether the date is in daylight saving time (1 if it is, otherwise 0)<br> O - Difference to Greenwich time (GMT) in hours (e.g., +0100)<br> P - Difference to Greenwich time (GMT) in hours:minutes (added in PHP 5.1.3)<br> T - Timezone abbreviation (e.g., EST, MDT)<br> Z - Timezone offset in seconds. The offset for timezones west of UTC is always negative, and for those east of UTC is always positive (-43200 to 50400)<br> c - ISO-8601 date (e.g., 2013-05-05T16:34:42+00:00)<br> r - RFC 2822 formatted date (e.g., Fri, 12 Apr 2013 12:01:05 +0200)<br> U - Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT). Additionally, the following predefined constants are available (since PHP 5.1.0): DATE_ATOM - Atom (e.g., 2013-04-12T15:52:01+00:00)<br> DATE_COOKIE - HTTP Cookies (e.g., Friday, 12-Apr-13 15:52:01 UTC)<br> DATE_ISO8601 - ISO-8601 (e.g., 2013-04-12T15:52:01+0000)<br> DATE_RFC822 - RFC 822 (e.g., Fri, 12 Apr 13 15:52:01 +0000)<br> DATE_RFC850 - RFC 850 (e.g., Friday, 12-Apr-13 15:52:01 UTC)<br> DATE_RFC1036 - RFC 1036 (e.g., Fri, 12 Apr 13 15:52:01 +0000)<br> DATE_RFC1123 - RFC 1123 (e.g., Fri, 12 Apr 2013 15:52:01 +0000)<br> DATE_RFC2822 - RFC 2822 (Fri, 12 Apr 2013 15:52:01 +0000)<br> DATE_RFC3339 - Same as DATE_ATOM (since PHP 5.1.3)<br> DATE_RSS - RSS (Fri, 12 Aug 2013 15:52:01 +0000)<br> DATE_W3C - World Wide Web Consortium (e.g., 2013-04-12T15:52:01+00:00)
timestamp Optional. Specifies a Unix timestamp as an integer. The default is the current local time (time()).

Technical Details

Return Value: Returns a formatted date string on success, or issues an E_WARNING and returns FALSE on failure.
PHP Version: 4+
--- ---
Changelog: PHP 5.1.0: The valid range of timestamps is from Friday, December 13, 1901, 20:45:54 GMT to Tuesday, January 19, 2038, 03:14:07 GMT. Prior to 5.1.0, on some systems (such as Windows), timestamps were limited from 01-01-1970 to 19-01-2038. <br>PHP 5.1.1: Added standard date/time format constants for specifying the format parameter.
--- ---

❮ Php Ref Misc Func Filesystem Linkinfo ❯