PHP | gmstrftime() Function
The gmstrftime() function is an inbuilt function in PHP which is used to format a GMT/UTC time/date according to local settings. The gmstrftime() function in PHP behaves in the same way as strftime() except that the time returned by the gmstrftime() function is Greenwich Mean Time (GMT). The $format and $timezone are sent as parameters to the gmstrftime() function and returns a string formatted according to the format specified using the given timestamp.
Syntax:
string gmstrftime( $format, $timestamp )
Parameters: This function accepts two parameters as mentioned above and described below:
- $format: It is a mandatory parameter which is used to specify the format of result.
- $timestamp: It is an optional parameter which is used to specify the UNIX timestamp that represents the date and/or time to be formatted.
Return Value: This function returns a formatted string according to the format specified by the given timestamp.
Exceptions:
- Month, weekday names and other language-dependent strings respect the current locale set with setlocale() function.
- If a timestamp is not given in the gmstrftime() function, it defaults to the value of time() or in other words to the current local time.
Below programs illustrate the gmstrftime() function in PHP:
Program 1:
<?php // Using gmstrftime() function to return the GMT time echo(gmstrftime("%B %d %Y, %X %Z", mktime(14, 0, 0, 8, 31, 18))); ?> |
August 31 2018, 14:00:00 GMT
Program 2:
<?php // Using gmstrftime() function to return the GMT time setlocale(LC_ALL, 'en_US'); echo(gmstrftime("%B %d %Y, %X %Z")); ?> |
August 31 2018, 09:55:21 GMT
Related Articles:
Reference: http://php.net/manual/en/function.gmstrftime.php
Recommended Posts:
- How to call a function that return another function in JavaScript ?
- How to get the function name from within that function using JavaScript ?
- How to get the function name inside a function in PHP ?
- PHP | max( ) Function
- D3.js | d3.map.set() Function
- D3.js | d3.min() function
- PHP Ds\Map sum() Function
- CSS | rgb() Function
- PHP | Ds\Map get() Function
- PHP | min( ) Function
- p5.js | box() Function
- D3.js | d3.hcl() Function
- D3.js | d3.rgb() Function
- p5.js | int() function
- PHP | dir() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



