-
How PHP gmdate() function will work
Following function is similar in nearly all respects to date() . It displays a date in a format specified in the first argument, except that the date string is calculated to be displayed in GMT.
gmdate() function will have Format a GMT/UTC date/time.
Syntax:
string gmdate ( string $format [, int $timestamp = time() ] )
Parameters:
Format: The format of the outputed date string. See the formatting options for the date() function.
Timestamp : The optional timestamp parameter is an integer Unix timestamp that defaults to the current local time if a timestamp is not given. In other words, it defaults to the value of time().
Return Values:
Function will return a formatted date string. If a non-numeric value will be used for timestamp than FALSE will be returned and an E_WARNING level error will be appeared.Example:
View Code PHP1 2 3 4
<?php echo date("M d Y H:i:s", mktime(0, 0, 0, 1, 1, 2013)); echo gmdate("M d Y H:i:s", mktime(0, 0, 0, 1, 1, 2013)); ?>
Output:
First line will print “Jan 01 2013 00:00:00″
Second line will print “Dec 31 2012 23:00:00″gmdate() function is of more use when combined with mktime() or gmmktime() than when using a static date string. Dates and times can be displayed in any order and combination, with any delimiters.
Tags: PHP gmdate function, PHP Script