(PHP 4, PHP 5, PHP 7, PHP 8)
gmstrftime — Format a GMT/UTC time/date according to locale settings
Warning
This function has been DEPRECATED as of PHP 8.1.0. Relying on this function is highly discouraged.
Alternatives to this function include:
Description
Warning
This function depends on operating system locale information, which might be inconsistent with each other, or not available at all. Instead use the IntlDateFormatter::format() method.
Parameters
format-
See description in strftime().
timestampThe optional
timestampparameter is an int Unix timestamp that defaults to the current local time iftimestampis omitted ornull. In other words, it defaults to the value of time().
Return Values
Returns a string formatted according to the given format string
using the given timestamp or the current
local time if no timestamp is given. Month and weekday names and
other language dependent strings respect the current locale set
with setlocale().
On failure, false is returned.
Changelog
| Version | Description |
|---|---|
| 8.0.0 |
timestamp is nullable now.
|
Examples
Example #1 gmstrftime() example
<?php
setlocale(LC_TIME, 'es_ES.UTF-8');
date_default_timezone_set('EST');
echo strftime("%B %d %Y %H:%M:%S", mktime(20, 0, 0, 12, 31, 98)) . "\n";
echo gmstrftime("%B %d %Y %H:%M:%S", mktime(20, 0, 0, 12, 31, 98));The above example will output:
Deprecated: Function strftime() is deprecated since 8.1, use IntlDateFormatter::format() instead in script on line 6 diciembre 31 1998 20:00:00 Deprecated: Function gmstrftime() is deprecated since 8.1, use IntlDateFormatter::format() instead in script on line 7 enero 01 1999 01:00:00
See Also
- IntlDateFormatter::format() - Format the date/time value as a string
- DateTimeInterface::format() - Returns date formatted according to given format
- strftime() - Format a local time/date according to locale settings
There are no user contributed notes for this page.