Home >>PHP Date Time Functions >PHP gmdate() Function
PHP gmdate() function is used to format a GMT/UTC date and time and return the formatted date strings. It is similar to the date() function but the only difference is it returns the time in Greenwich Mean Time (GMT). It accepts two parameters $format and $timestamp. It returns a formatted date string as output on success and FALSE or E_WARNING on failure.
Syntax:
gmdate(format, timestamp);
Parameter | Description |
---|---|
format | This is a required parameter. This parameter defines the format of the output date string. |
timestamp | This is an optional parameter. This parameter defines the integer Unix timestamp. |
Here is an example of gmdate() function in PHP:
<html> <body> <?php echo gmdate("d-m-Y")."<br>"; echo gmdate("d-M-Y")."<br>"; echo gmdate("l")."<br>"; echo gmdate("jS F,Y")."<br>"; echo gmdate("jS M, Y (l)")."<br>"; ?> </body> </html>
Example 2:
<html> <body> <?php echo gmdate("d-m-Y",1581638400)."<br>"; echo gmdate("d-M-Y",1581638400)."<br>"; echo gmdate("l",1581638400)."<br>"; echo gmdate("jS F,Y",1581638400)."<br>"; echo gmdate("jS M, Y (l)",1581638400)."<br>"; ?> </body> </html>