note 109595 deleted from function.date by peehaa
| From: | peehaa@php.net | Date: | Fri, 06 Jan 2017 15:55:01 +0000 |
| Subject: | note 109595 deleted from function.date by peehaa | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-208703@lists.php.net to get a copy of this message | ||
Note Submitter: stokestack at gmail dot com
----
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.