Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #18886

Re: UTC to local time, allowing for US daylight savings time.

From Lew Pitcher <lew.pitcher@digitalfreehold.ca>
Newsgroups comp.lang.php
Subject Re: UTC to local time, allowing for US daylight savings time.
Date 2022-03-14 15:10 +0000
Organization A noiseless patient Spider
Message-ID <t0nlt0$fd8$1@dont-email.me> (permalink)
References <t0niui$a4e$1@gioia.aioe.org>

Show all headers | View raw


On Mon, 14 Mar 2022 10:20:01 -0400, 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?

One possibility (which may be overkill for you; you decide) would
be to change the "date.timezone" value in php.ini to name EST5EDT
rather than the default UTC
  [Date]
  ; Defines the default timezone used by the date functions
  ; http://php.net/date.timezone
  date.timezone = EST5EDT         ; override UTC default

From there, you can use the php date functions, and they will
reflect EST5EDT dates and times

HTH

-- 
Lew Pitcher
"In Skills, We Trust"

Back to comp.lang.php | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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