note 70821 added to function.date
| From: | phil at hogarthrange dot com | Date: | Mon, 30 Oct 2006 06:46:56 +0000 |
| Subject: | note 70821 added to function.date | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-119243@lists.php.net to get a copy of this message | ||
I had date/time stored in a database in GMT
and needed to display it according to the users timezone.
Including: daylight saving/summer time...
Finally found this:
<?php
putenv("TZ=Australia/Sydney");
$LocalTime = date('d M Y - h:i:s a O ',$GmtTime);
print "<p>$LocalTime in:". getenv('TZ')."</p>";
?>
Outputs something like this:
31 Oct 2006 - 05:11:28 pm +1100 in:Australia/Sydney
Substitute Australia/Sydney with anything on the list here:
http://www.theprojects.org/dev/zone.txt
This may be obvious, but it took me ages to sort out.
Hope this helps someone.
----
Server IP: 203.220.0.234
Probable Submitter: 210.10.221.245
----
Manual Page -- http://www.php.net/manual/en/function.date.php
Edit -- https://master.php.net/note/edit/70821
Del: integrated -- https://master.php.net/note/delete/70821/integrated
Del: useless -- https://master.php.net/note/delete/70821/useless
Del: bad code -- https://master.php.net/note/delete/70821/bad+code
Del: spam -- https://master.php.net/note/delete/70821/spam
Del: non-english -- https://master.php.net/note/delete/70821/non-english
Del: in docs -- https://master.php.net/note/delete/70821/in+docs
Del: other reasons-- https://master.php.net/note/delete/70821
Reject -- https://master.php.net/note/reject/70821
Search -- https://master.php.net/manage/user-notes.php