gmdate function format a GMT/UTC date/time. This function is similar to date() except in finding the Greenwich Mean Time (GMT). It returns a formatted date string. If a non-numeric value is used for timestamp , FALSE is returned and an E_WARNING level error is emitted.
Syntax on gmdate() Function PHP
string gmdate ( string $format [, int $timestamp ] )
Parameters on gmdate() Function PHP
format - Format is essential. It specifies how to return the result:
timestamp - Optional and integer parameter. It defaults to the current local time if Unix timestamp is not specified.
Example of gmdate() Function PHP:
<?php
echo("Result with date():<br />");
echo(date("l") . "<br />");
echo(date("l dS \of F Y h:i:s A") . "<br />");
echo("Mar 8,1978 was on a ".date("l", mktime(0,0,0,8,3,1978))."<br />");
echo(date(DATE_RFC822) . "<br />");
echo(date(DATE_ATOM,mktime(0,0,0,8,3,1978)) . "<br /><br />");
echo("Result with gmdate():<br />");
echo(gmdate("l") . "<br />");
echo(gmdate("l dS \of F Y h:i:s A") . "<br />");
echo("Mar 8,1978 was on a ".gmdate("l", mktime(0,0,0,8,3,1978))."<br />");
echo(gmdate(DATE_RFC822) . "<br />");
echo(gmdate(DATE_ATOM,mktime(0,0,0,8,3,1978)) . "<br />");
?>
Output: The output of the code above could be something like this:
Result with date():
Friday
Friday 28th of August 2009 02:26:22 PM
Mar 8, 1978 was on a Wednesday
Fri, 28 Aug 2009 14:26:22 CET
1978-03-08T00:00:00+05300
Result with gmdate():
Friday
Friday 28th of August 2009 02:26:22 PM
Mar 8, 1978 was on a Wednesday
Fri, 28 Jan 2009 08:04:22 GMT
1978-03-07T18:30:00+0000