Tutorials Point

  Learning PHP
  Advanced PHP
  PHP Function Reference
  PHP Useful Resources
  Selected Reading

Copyright © 2014 by tutorialspoint

  Home     References     Discussion Forums     About TP  

PHP Function gmdate()




string gmdate ( string $format [, int $timestamp] );

Definition and Usage

This is identical to the date() function except that the time returned is Greenwich Mean Time (GMT).


formatRequired. The format of the outputted date string. See the formatting options for the date() function.
timestampOptional. This 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 Value

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.


Following is the usage of this function:

echo date("M d Y H:i:s", mktime(0, 0, 0, 1, 1, 2007));
echo gmdate("M d Y H:i:s", mktime(0, 0, 0, 1, 1, 2007));

This will produce following result:

Jan 01 2007 00:00:00
Jan 01 2007 07:00:00

previous Printer Friendly