note 109595 added to function.date
| From: | stokestack at gmail dot com | Date: | Tue, 31 Jul 2012 21:37:54 +0000 |
| Subject: | note 109595 added to function.date | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-189534@lists.php.net to get a copy of this message | ||
If you want to find your server's timezone offset from GMT, it seems as though you could just
do:
date('Z')
to get the number of seconds offset. But PHP requires that you call date_default_timezone_set(). So
if you have to hard-code a timezone, why not simply hard-code a variable that tells you the offset
from GMT? If you set the timezone to GMT, the dates in your database will still be in local time,
but time('Z') will return zero.
To keep your code portable across servers in different timezones, you can do this:
date_default_timezone_set(date_default_timezone_get())
This keeps PHP from complaining that you haven't called date_default_timezone_set(), but makes
your code portable. Ridiculous.
----
Server IP: 69.147.83.197
Probable Submitter: 76.87.49.18
----
Manual Page -- http://www.php.net/manual/en/function.date.php
Edit -- https://master.php.net/note/edit/109595
Del: integrated -- https://master.php.net/note/delete/109595/integrated
Del: useless -- https://master.php.net/note/delete/109595/useless
Del: bad code -- https://master.php.net/note/delete/109595/bad+code
Del: spam -- https://master.php.net/note/delete/109595/spam
Del: non-english -- https://master.php.net/note/delete/109595/non-english
Del: in docs -- https://master.php.net/note/delete/109595/in+docs
Del: other reasons-- https://master.php.net/note/delete/109595
Reject -- https://master.php.net/note/reject/109595
Search -- https://master.php.net/manage/user-notes.php