Home >>PHP Date Time Functions >PHP gmstrftime() Function

PHP gmstrftime() Function

PHP gmstrftime() Function

PHP gmstrftime() function is used to format a GMT/UTC time/date according to the local settings. It is similar to the strftime() function except that the time returned by the gmstrftime() function is Greenwich Mean Time (GMT). It accepts two parameters $format and $timezone. It returns a string formatted according to the format specified using the given timestamp value.

Syntax:

gmstrftime(format, timestamp);

Parameter Values

Parameter Description
format This is a required parameter. This parameter defines how to return the result.
timestamp This is an optional parameter. This parameter defines a Unix timestamp that represents the date and time to be formatted.

Here is an example of gmstrftime() function in PHP:

<html>
<body>
<?php
echo gmstrftime("%d %B %Y, %X %Z",mktime(20,0,0,06,10,2020));
?>
</body>
</html>
Output:
10 June 2020, 20:00:00 GMT

Example 2:

<html>
<body>
<?php
echo(gmstrftime("%d %B %Y, %X %Z",mktime(20,43,22,06,10,2020))."<br>");
setlocale(LC_ALL,"it_IT.UTF-8");
echo(gmstrftime("%d %B, %Y. %A. %X %Z"));
?>
</body>
</html>
Output:
10 June 2020, 20:43:22 GMT
01 February, 2020. Saturday. 09:58:33 GMT

No Sidebar ads