Working with time zones
The Go time.Time
value includes time.Location
, which can be one of two things:
- A real location, such as
America/Denver
. If this is the case, the actual time zone depends on the time value. ForDenver
, the time zone will be eitherMDT
(Mountain Daylight Time) orMST
(Mountain Standard Time) depending on the actual time value - A fixed time zone that gives the offset.
Some applications work with local time. This is the date/time value captured at a particular location, and interpreted as the same value everywhere, as opposed to being interpreted as the same point in time. Birthdays (and thus, ages) are usually interpreted using local time. That is, if you are born on 2005-07-14, you will be considered 2 years old in New York (Eastern time zone) on 2007-07-14 at 00:00, but still be 1 year old at the same moment in time in Los Angeles, which is 2007-07-13 at 21:00 (Pacific time zone).
How to do it...
If you are working with moments in time...