Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #18890
| From | bill <william@TechServSys.com> |
|---|---|
| Newsgroups | comp.lang.php |
| Subject | Re: UTC to local time, allowing for US daylight savings time. |
| Date | 2022-03-16 07:05 -0400 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <t0sga7$1efu$1@gioia.aioe.org> (permalink) |
| References | <t0niui$a4e$1@gioia.aioe.org> <j994msF7u12U1@mid.individual.net> |
On 3/14/2022 11:18 AM, J.O. Aho wrote:
> On 14/03/2022 15.20, bill wrote:
>> I have a UTC time and I need to display it as local time
>> (always US Eastern time).
>>
>> I could check to see if we are now in standard or daylight time
>> and then add the appropriate number of hours, but it seems
>> there should be an easier way with php automagically doing the
>> proper conversion.
>>
>> Any suggestions?
>
> something like this?
>
> date_default_timezone_set('UTC');
> utc_datetime = '2008-08-03 12:35:23';
> $datetime = new DateTime(utc_datetime);
> $ny_time = new DateTimeZone('America/New_York');
> $datetime->setTimezone($ny_time);
> echo $datetime->format('Y-m-d H:i:s');
>
> You have also possibility to use javascript in the UI, then you
> could quite simply get to the users local time without having a
> config.
>
>
That works. Thank you very much.
-bill
Back to comp.lang.php | Previous | Next — Previous in thread | Find similar | Unroll thread
UTC to local time, allowing for US daylight savings time. bill <william@TechServSys.com> - 2022-03-14 10:20 -0400
Re: UTC to local time, allowing for US daylight savings time. Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2022-03-14 15:10 +0000
Re: UTC to local time, allowing for US daylight savings time. bill <william@TechServSys.com> - 2022-03-15 12:39 -0400
Re: UTC to local time, allowing for US daylight savings time. Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2022-03-15 16:46 +0000
Re: UTC to local time, allowing for US daylight savings time. bill <william@TechServSys.com> - 2022-03-16 07:06 -0400
Re: UTC to local time, allowing for US daylight savings time. "J.O. Aho" <user@example.net> - 2022-03-14 16:18 +0100
Re: UTC to local time, allowing for US daylight savings time. bill <william@TechServSys.com> - 2022-03-16 07:05 -0400
csiph-web