Re: date.timezone E_WARNING -- Really necessary? What's the rationale?
| From: | Nikita Popov | Date: | Thu, 23 May 2013 18:48:53 +0000 |
| Subject: | Re: date.timezone E_WARNING -- Really necessary? What's the rationale? | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-67459@lists.php.net to get a copy of this message | ||
On Thu, May 23, 2013 at 8:40 PM, Daniel Lowrey <rdlowrey@gmail.com> wrote:
> I'm probably not the typical PHP user; I spend 99% of my PHP time
> using the CLI (and not web SAPIs).
> This means that I frequently run PHP without an .ini file. As a
> result, when I use any of the date/time
> functionality I invariably end up with this awesomeness:
>
> > Warning: date(): It is not safe to rely on the system's timezone
> settings blah blah blah.
>
> Could I run
$ php -d date.timezone=UTC myfile.php? Of course,
> but
> should that really be necessary?
> It seems to me this warning caters to the very lowest common
> denominator among PHP devs who can't
> be bothered to understand how PHP handles timezones. The warning also
> seems to assume that people only
> use PHP as a web framework and not as an actual programming language
> (otherwise I wouldn't have to
> explain to the CLI which timezone I want to use). I don't need php.ini
> ... I want to use PHP to *program*.
>
> If it's going to default to UTC anyway should there really be an
> E_WARNING? Can't PHP just quietly use UTC?
> The "U" in UTC *does* stand for "Universal," after all. It's a
> sensible default and as such shouldn't
> merit a warning. Besides, if someone doesn't understand what's
> happening and gets unexpected date/time
> results the first thing they're going to do (I hope) is hit their
> favorite search engine for "set PHP timezone."
>
> Perhaps I'm the only person to experience ongoing annoyance at the
> hands of this protective
> "feature?" Is there a substantive reason why this warning exists other
> than the error message's
> suggestion that "you most likely misspelled the timezone identifier?"
> I understand that one of PHP's
> most attractive features is ease-of-use for programming novices but
> you can only go so far in
> preventing people who don't know what they're doing from shooting
> themselves in the foot.
>
> I'm not sure if it's possible but perhaps a compromise might be to
> disable this warning in the CLI, at least?
Fully agreed. The warning is very annoying when using CLI. And even when
not using CLI: The timezone is usually only relevant in production. I don't
care if times are off a few hours when developing stuff.
Nikita