gmstrftime

(PHP 4, PHP 5)

gmstrftimeФорматирует дату/время по Гринвичу с учетом текущей локали

Описание

string gmstrftime ( string $format [, int $timestamp = time() ] )

Эта функция идентична функции strftime() за исключением того, что возвращает время по Гринвичу (GMT). Например, при запуске на системе, где установлено Eastern Standard Time (GMT-0500), первая строка из примера ниже выведет "Dec 31 1998 20:00:00", тогда как вторая - "Jan 01 1999 01:00:00".

Список параметров

format

Смотрите описание функции strftime().

timestamp

Необязательный параметр timestamp представляет собой integer метку времени, по умолчанию равную текущему локальному времени, если timestamp не указан. Другими словами, значение по умолчанию равно результату функции time().

Возвращаемые значения

Возвращает строку, отформатированную согласно указанному формату и с использованием временной метки из параметра timestamp или текущего локального времени, если временная метка не была указана. Названия месяцев, дней недели и других языкозависимых строк, будут показаны с учетом настроек текущей локали, установленных с помощью функции setlocale().

Примеры

Пример #1 Пример использования функции gmstrftime()

<?php
setlocale
(LC_TIME'en_US');
echo 
strftime("%b %d %Y %H:%M:%S"mktime(2000123198)) . "\n";
echo 
gmstrftime("%b %d %Y %H:%M:%S"mktime(2000123198)) . "\n";
?>

Смотрите также

  • strftime() - Форматирует текущую дату/время с учетом текущих настроек локали

Коментарии

To get a RFC 850 date (used in HTTP) of the current time:

gmstrftime ("%A %d-%b-%y %T %Z", time ());

This will get for example:
Friday 25-Jun-04 03:30:23 GMT

Please note that times in HTTP-headers _must_ be GMT, so use gmstrftime() instead of strftime().
2004-06-25 02:27:15
http://php5.kiev.ua/manual/ru/function.gmstrftime.html
HTTP 1.1 (RFC 2068) requires an RFC 1123 date with a four digit year, so the correct format to use for a Last-modified header would look something like this:

<?php
header
("Last-modified: " 
gmstrftime("%a, %d %b %Y %T %Z",getlastmod()));
?>
2004-10-10 12:15:34
http://php5.kiev.ua/manual/ru/function.gmstrftime.html
gmstrftime() should not be used to generate a RFC 850 date for use in HTTP headers, since its output is affected by setlocale().

Use gmdate instead:

gmdate('D, d M Y H:i:s') . ' GMT';
2005-02-05 09:27:17
http://php5.kiev.ua/manual/ru/function.gmstrftime.html
If you want the dutch time on your pages and you are hosted on a server in the USA you can easily change it this way:

<?php
setlocale
(LC_TIME'nl_NL');
$tgl gmstrftime("%d %B %Y - %H:%M uur",time()+3600);
?>

Then use $tgl to display the right time.
Note the +3600 is a day light savings time correction.
The result: 22 maart 2005 - 16:39 uur

First I used the normal date function and this was the previous result: March 22, 2005 - 04:28 AM

I needed it for a dutch guestbook.

I'm new to PHP and it took me a while to find it out and maybe it's of no use for experienced PHP programmers but I thought people can always ignore my post :)
2005-03-22 09:50:13
http://php5.kiev.ua/manual/ru/function.gmstrftime.html

    Поддержать сайт на родительском проекте КГБ