Re: Re: Time zone in date function
| From: | Matijn Woudt | Date: | Tue, 31 Jan 2012 16:15:48 +0000 |
| Subject: | Re: Re: Time zone in date function | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-316436@lists.php.net to get a copy of this message | ||
On Tue, Jan 31, 2012 at 4:22 PM, Jonesy <gmane@jonz.net> wrote:
> On Tue, 31 Jan 2012 14:57:41 +1300, Simon J Welsh wrote:
>> On 31/01/2012, at 2:55 PM, Ron Piggott wrote:
>>
>>>
>>> On my clients account when I use ?echo date(?D, d M Y H:i:s');? the output is 5
>>> hours ahead of us. How do I change it to my local time? Is there a way to specify ?Eastern? time
>>> zone?
>>>
>>> I expect this would work:
>>>
>>> echo date(?D, d M Y H:i:s' , ( strtotime( date(?D, d M Y H:i:s') ? 21600 )
>>> ) );
>>>
>>> I would prefer to specify Eastern time, so if the web host changes a server setting it
>>> will remain in Eastern time zone. Ron
>>
>> You can set the timezone for your script using date_default_timezone_set()
>> http://php.net/manual/en/function.date-default-timezone-set.php
>
> (wrap your lines, folks!)
>
> Is there a reason _not_ to use viz:
>
> putenv("TZ=America/Anguilla");
> ??
>
> Or, is it simple "Just The Linux Way"(tm) , i.e. there's
> always more than one way to do a 'thing'?
>
> Jonesy
From the PHP Manual:
"every call to a date/time function will generate a E_NOTICE if the
timezone isn't valid, and/or a E_WARNING message if using the system
settings or the TZ environment variable."
So that will generate E_WARNING messages.
- Matijn