Dutch PHP Conference 2025 - Call For Papers

gmstrftime

(PHP 4, PHP 5, PHP 7, PHP 8)

gmstrftimeFormat a GMT/UTC time/date according to locale settings

Увага

Ця функція ЗАСТАРІЛА, починаючи з PHP 8.1.0. Вкрай не рекомендується на неї покладатися.

Її можна замінити на:

Опис

gmstrftime(string $format, ?int $timestamp = null): string|false

Behaves the same as strftime() except that the time returned is Greenwich Mean Time (GMT). For example, when run in Eastern Standard Time (GMT -0500), the first line below prints "Dec 31 1998 20:00:00", while the second prints "Jan 01 1999 01:00:00".

Увага

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.

Параметри

format

See description in strftime().

timestamp

Необов'язковий параметр timestamp — це позначка часу Unix типу int, яка стандартно дорівнює поточному місцевому часу, якщо timestamp не вказаний або null. Тобто є результатом функції time().

Значення, що повертаються

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.

Журнал змін

Версія Опис
8.0.0 timestamp is nullable now.

Приклади

Приклад #1 gmstrftime() example

<?php
setlocale
(LC_TIME, 'en_US');
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)) . "\n";
?>

Прогляньте також

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top