Re: Re: Why does PHP consider the system's timezone unreliable, and is date_default_timezone_set() required?
| From: | Stuart Dallas | Date: | Mon, 17 Feb 2014 17:46:58 +0000 |
| Subject: | Re: Re: Why does PHP consider the system's timezone unreliable, and is date_default_timezone_set() required? | ||
| References: | 1 | Groups: | php.general php.general |
| Request: | Send a blank email to php-general+get-322920@lists.php.net to get a copy of this message | ||
On 17 Feb 2014, at 17:27, Tim Streater <tim@clothears.org.uk> wrote:
> On 17 Feb 2014 at 17:04, Stuart Dallas <stuart@3ft9.com> wrote:
>
>> On 17 Feb 2014, at 16:55, Tim Streater <tim@clothears.org.uk> wrote:
>
>>> People shouldn't assume that all execution of PHP takes place on a server,
>>> because it doesn’t.
>>
>> I’m not going to get in to the arguments for and against because it was done
>> to death at the time, but you must understand that your use case is incredibly
>> rare for PHP.
>
> You sure? I would have thought that as PHP is so easy to use, lots of people might write all
> their local command line scripts in it. I do - it would never occur to me not to.
I write a lot of CLI scripts using PHP, but they’re all executed server-side. I have very few
local scripts because there’s little that I need to do enough to warrant a script that can’t be
done by piping a few existing commands together.
>> To get around your issue you can use the following to use the
>> system timezone without getting the notice:
>>
>> date_default_timezone_set(@date_default_timezone_get());
>
> This just gives me UTC, not the timezone the user has set.
Sorry, I didn’t have time to test it. I don’t know what else to suggest. If these are local CLI
scripts for your own usage, why not just hardcode timezone? If the timezone is actually important
for your scripts you can instead set the timezone in your local php.ini which will make it correct
unless you ever travel and need it to be local, at which point I’d wonder what you’re doing that
needs such a reactive timezone value.
-Stuart
--
Stuart Dallas
3ft9 Ltd
http://3ft9.com/