O'Reilly logo

Go Standard Library Cookbook by Radomir Sohlich

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How it works...

The time package contains the Parse function for parsing the string with time information.

The format of an incoming date string is given by the referential date, formatted to the matching format. Remember that the reference time is Jan 2 15:04:05 2006 MST.

If the given time string does not contain the information about the timezone, the result of the Parse function will always be in UTC.

If the timezone information is provided, then the time is always the time instant in the provided timezone. 

The ParseInLocation function accepts the third argument, which is the location. If the time string does not contain any timezone information, then the time is parsed to the Time instance in given location.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required