Re: Why does PHP consider the system's timezone unreliable, and is date_default_timezone_set() required?
| From: | Tim Streater | Date: | Mon, 17 Feb 2014 16:55:00 +0000 |
| Subject: | Re: Why does PHP consider the system's timezone unreliable, and is date_default_timezone_set() required? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-322911@lists.php.net to get a copy of this message | ||
On 17 Feb 2014 at 16:46, Stuart Dallas <stuart@3ft9.com> wrote:
> On 17 Feb 2014, at 13:14, Martin Tournoij <martin@arp242.net> wrote:
>
>> Is this somehow unreliable? This is all POSIX stuff, so I would expect it to
>> work well on at least all POSIX sysyems, or am I missing something?
>
> It doesn’t mean unreliable in the technical sense, just that it’s very
> common for the timezone of a server to be different from the timezone you
> want, so it forces you to make a choice. This issue extends beyond shared
> hosting to dedicated servers where the person who set it up hasn’t changed
> the timezone from the default. PHP is simply reminding you to check that the
> timezone is what you want it to be rather than being surprised when it appears
> that the time is wrong.
That may be a reasonable thing to do if your PHP is executing on a server. In my case it's on a
user's machine and obtaining what the system thinks is the timezone value, just so I can tell
PHP, has proved to be a pain in the bum. At least under unix (and so OS X) it seems I can look at
what:
/etc/localtime
(which is a link) equates to. I couldn't find any reliable way at all to do it under Windows.
People shouldn't assume that all execution of PHP takes place on a server, because it
doesn't.
--
Cheers -- Tim