Re: Time-Zone juggling

From: Date: Thu, 09 Nov 2006 16:46:08 +0000
Subject: Re: Time-Zone juggling
References: 1 2 3 4 5 6 7  Groups: php.general 
Request: Send a blank email to php-general+get-244433@lists.php.net to get a copy of this message
On 11/9/06, M.Sokolewicz <tularis@php.net> wrote:
David Giragosian wrote: On 11/8/06, Travis Doherty <travis@tixtime.com> wrote:
David Giragosian wrote:
Does Daylight Savings alter Zulu time? (I'm guessing "yes"). How did
the
military deal with that? I use a date-time field as a primary key in db tables that get an insert a minute. I had to jump through a number of hoops to turn off DST on
the
(RH Linux) server. David
UTC (or GMT, or Zulu, or Z) does not observe Daylight Savings Time. In any database that you store timestamps and need to know exactly what that timestamp means you should use UTC, then use application logic to translate to the users time zone. Another option would be to store epoch time (seconds since the OS's epoch) and work the same result from that, I prefer storing human-readable timestamps even if you have to do the datemath in your head to read them in your own timezone. Epoch does not count leap-seconds like UTC so it can be off by a tiny bit at any given time. Epoch time also differs on different operating systems - Unix is 1970-01-01 at 00:00:00 UTC, Windows seems to use 1601-01-01 at 00:00:00 UTC... I don't know if that would ever matter though - I imagine the database server would mask this and the application would port to windows without problems (no idea.) UTC has no DST from: http://en.wikipedia.org/wiki/Time_zone
Due to daylight saving time, UTC is local time at the Royal
Observatory,
Greenwich <http://en.wikipedia.org/wiki/Royal_Observatory%2C_Greenwich> only between 01:00 UTC on the last Sunday in October and 01:00 UTC on the last Sunday in March. For the rest of the year, local time there is UTC+1 <http://en.wikipedia.org/wiki/UTC%2B1>, known in the United Kingdom <http://en.wikipedia.org/wiki/United_Kingdom> as British Summer Time <http://en.wikipedia.org/wiki/British_Summer_Time> (BST). Similar circumstances apply in many places. << ** Travis Doherty TixTime
We are using now() in the MySQL db to insert current time. Database version is 4.0.24. I see that in 4.1.* there is utc_timestamp(). Anybody know if this function avoids DST? Might be worth the hassle of upgrade and possible code changes in the PHP scripts to obtain this feature. << Shudder >> Thanks, David you don't quite understand what UTC is, do you :) UTC doesn't have DST. It just doesn't, at all. If it returns a timestamp in UTC offset, it will "avoid" DST for you... - tul
We use now() to do timestamp inserts in the MySQL db. "now()" in MySQL is based upon the OS time, which is obviously affected by timezone setting as an offset from UTC. When I've set the RH server to use UTC, the OS time was still affected by the "rule" which altered UTC to the timezone setting (I'm in the process of moving my office or else I'd be able to find the document describing how to alter the RH OS to not obey DST changes). My question is based upon this experience. If "select utc_timestamp() in MySQL truly returns the UTC with timezone offset and without any adjustments for DST, that would be just peachy. Thanks, David

« previous php.general (#244433) next »