Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^3: Question regarding Time::Piece and timezones

by Marshall (Canon)
on Jan 14, 2021 at 12:26 UTC ( [id://11126903]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Question regarding Time::Piece and timezones
in thread Question regarding Time::Piece and timezones

Yes, there are many moving parts to time/date calculations!

I personally always use gmtime(), which is close to utc time.
There is a slight difference between gm and utc time, but not much.
The difference is so small that I don't want to argue about it.

I recommend using GM or UTC time for all values stored in a DB.
Use a a conversion module like Time::Piece for translation to
translate the DB time to a user time zone.

My local government had a problem with the fall time change.
This actually allowed bars to remain open for one extra hour on one day of the year.
They fixed that "problem".
gmtime() just marches onward- there is no "fall back".

  • Comment on Re^3: Question regarding Time::Piece and timezones

Replies are listed 'Best First'.
Re^4: Question regarding Time::Piece and timezones
by hippo (Bishop) on Jan 14, 2021 at 13:25 UTC
    There is a slight difference between gm and utc time, but not much. The difference is so small that I don't want to argue about it.

    No need to argue when there's a source to cite.


    🦛

Re^4: Question regarding Time::Piece and timezones
by atcroft (Abbot) on Jan 15, 2021 at 00:03 UTC

    Yes, and were it my preference the data would be in GMT/UTC until someone asked for it in another TZ. (And yes, I'm aware there is a slight difference in GMT v. UTC, but most people aren't aware of them until they hear about a "leap second", or the possible horror of a "negative leap second".) Unfortunately the data I am given includes time stamps from at least five different time zones, and it falls to me to compare them as part of other processing. Since Time::Piece is core and pops up periodically as a suggestion when questions arise about dates/times including TZs (such as a response to a post yesterday), I thought I should go ahead and post my question.

Re^4: Question regarding Time::Piece and timezones
by jszinger (Scribe) on Jan 15, 2021 at 18:06 UTC
    On Linux at least, gmtime() actually returns UTC. As explained in hippo’s link, GMT in common use is often used as a synonym for UTC, but GMT has other meanings differing by a few seconds or 12 hours!.
      From https://www.apparent-wind.com/gmt-explained.html
      Prior to 1925, astronomers reckoned mean solar time from noon so that when the mean sun was on the meridian, it was actually 00:00 GMT. This practice arose so that astronomers wouldn't have a change in date during a night's observing. Some in the astronomical community still use the pre-1925 definition of GMT in the analysis of old data although it is recommended that the term Greenwich Mean Astronomical Time now be used to refer to time reckoned from noon.
        jszinger, thanks for the info!

        In my work, I only process computer generated logging files and by definition of the "problem set", I never see any date/time before the "computer era".

        But I enjoyed this info! Thanks!

Re^4: Question regarding Time::Piece and timezones
by Bod (Parson) on Jan 14, 2021 at 23:55 UTC
    I recommend using GM or UTC time for all values stored in a DB.
    Use a a conversion module like Time::Piece for translation to
    translate the DB time to a user time zone.

    If my code is connecting to a database, I usually use that to do all the time arithmetic and conversion that I need...

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11126903]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2024-04-25 15:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found