note 51706 deleted from function.gmdate by nlopess

From: Date: Fri, 08 Apr 2005 16:25:00 +0000
Subject: note 51706 deleted from function.gmdate by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-87709@lists.php.net to get a copy of this message
Note Submitter: wynnesome Reason: spam ---- I want to thank www.l-serwis.wpt.pl for the $zone=3600*0 //GMT $zone=3600*1 //CET $zone=3600*-5//USA $date=gmdate("D M Y H:i", time() + $zone); solution a few posts up, which worked for me where the (putenv) and a couple of other functions discussed here and elsewhere were not bringing back anything but GMT time when I tried them. I have a web site supporting a local retail store, and most if not all posts to my guestbook will be coming from the local area, so it makes much more sense to be able to have the posts shown in local time instead of GMT or the server's TZ. For my site, I modified the displayed date format, and also instead of setting a fixed time zone, I included a condition for the time zone to correct itself based upon daylight savings time. Then later when the guestbook displays the username and time of the post, it just echoes the $time variable and the date/time are displayed with the appropriate time zone notation. $daylight = gmdate(I); $zone = 3600*0; //GMT $zone = 3600*1; //CET if ($daylight = "1") { $zone = 3600*-6; } elseif ($daylight = "0") { $zone = 3600*-7; } //USA $date = gmdate("F jS, Y, g:ia", time() + $zone); if ($daylight = "1") {$time = $date . " MDT"; } elseif ($daylight = "0") {$time = $date . " MST"; } When the time is displayed, it shows up something like: Time: April 7th, 2005, 9:41pm MDT. Again, thanks and all credit to www.l-serwis.wpt.pl for this function which I've modified only slightly to meed my specific needs. I hope this is helpful to anyone looking to display local time on their site.

« previous php.notes (#87709) next »