downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

idate> <gmmktime
Last updated: Fri, 14 Aug 2009

view this page in

gmstrftime

(PHP 4, PHP 5)

gmstrftimeFormate une date/heure GMT/CUT en fonction de la configuration locale

Description

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

gmstrftime() se comporte exactement comme strftime() hormis le fait que l'heure utilisée est celle de Greenwich (Greenwich Mean Time, GMT). Par exemple, dans la zone Eastern Standard Time (est des USA) est GMT -0500, la première ligne de l'exemple ci-dessous affiche "Dec 31 1998 20:00:00", tandis que la seconde affiche "Jan 01 1999 01:00:00".

Liste de paramètres

format

Voir la description de la fonction strftime().

timestamp

Le paramètre optionnel timestamp est un timestamp Unix de type entier qui vaut par défaut l'heure courante locale si le paramètre timestamp n'est pas fourni. En d'autres termes, il faut par défaut la valeur de la fonction time().

Valeurs de retour

Retourne une chaîne de caractères formatée suivant le format donné par le paramètre timestamp ou la date courante si aucun paramètre timestamp n'est fourni. Les noms des mois, des jours de la semaine et des autres chaînes dépendant d'une localisation donnée, respectent la localisation courante définie par la fonction setlocale().

Exemples

Exemple #1 Exemple avec 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";
?>

Voir aussi

  • strftime() - Formate une date/heure locale avec la configuration locale



idate> <gmmktime
Last updated: Fri, 14 Aug 2009
 
add a note add a note User Contributed Notes
gmstrftime
pvdster at hotmail dot com
22-Mar-2005 03:50
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 :)
peter dot albertsson at spray dot se
05-Feb-2005 03:27
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';
yellow dot snow at huskies dot com
10-Oct-2004 04:15
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()));
?>
neo at gothic-chat d0t de
25-Jun-2004 06:27
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().

idate> <gmmktime
Last updated: Fri, 14 Aug 2009
 
 
show source | credits | sitemap | contact | advertising | mirror sites