5/3/2023 0 Comments Perl strftimeFor example, the Gregorian calendar’s epoch is January 1, 1 CE. In a sense, local time is the display format, while UTC is the storage format.Įpoch is a generic term referring to the “start” of any particular system. While UTC is great for internal use, most people want to see datetimes in terms of their location. The local time is UTC plus the local time zone offset. For example, there is an “EST” at -0500 and +1000. The latter shorthand is commonly used, but it should probably be avoided because these short names are not unique or definitive. It defines zones according to names like “America/New_York”, as opposed to “EST”. The definitive source of time zone offsets and rules is the Olson time zone database. The upshot of all this is that any code that represents time zones as fixed offset will probably start producing errors once date math gets involved. If I have a local datetime for the Eastern US of 14:15:00 and I add six months to that datetime, then I will have crossed a DST change. This greatly complicates math when dealing with non-UTC datetimes. Because time zones are determined by governments, use of Daylight Saving Time, and the base offsets, have changed over time, and may change again in the future. However, when Daylight Saving Time is in effect, the offset becomes -0400, four hours behind UTC. This means that 12:00 (noon) UTC becomes 07:00 (AM). The eastern US has an offset of -0500 from UTC, five hours behind UTC. Time zones are complicated by the use of Daylight Saving Time, which changes the actual offset of a given location to vary over the course of the year. Adelaide, Australia has an offset of nine and a half hours ahead of UTC, and Nepal has an offset five hours and forty-five minutes ahead of UTC. Most, but not all, time zones are in offsets of whole hours. Time zones, as mentioned above, are defined as an offset from UTC. UTC is a good standard for the internal representation of dates and times, as it makes comparing datetimes or doing datetime math much easier. In this system UTC is Z, sometimes called “Zulu”. The US military has a set of terms used for time zones around the world based on the alphabet (A-Z). The widely used term GMT (Greenwich Mean Time) refers to a time zone that is equivalent to UTC. Time zones around the world are specified as an offset from UTC. UTC time is measured at the prime meridian (O degrees longitude). It is an international standard which is kept using atomic clocks, and is kept to within 0.9 seconds of the rotation of the earth on its axis in order to work well with traditional standards of time-keeping. UTC stands for “Coordinated Universal Time”. Here are some terms that I’ll be using in this article: In order to understand what you might want to do with dates and times, it’s good to have a handle on some basic concepts.
0 Comments
Leave a Reply. |