Dealing with time zones is hard. A good way to handle the different time zones is to keep one timezone as referential in the system and convert the others if needed. This recipe shows you how the conversion of time between time zones is done.
Converting between time zones
How to do it...
- Open the console and create the folder chapter04/recipe08.
- Navigate to the directory.
- Create the timezones.go file with the following content:
package main
import (
"fmt"
"time"
)
func main() {
eur, err := time.LoadLocation("Europe/Vienna")
if err != nil {
panic(err)
}
t := time.Date(2000, 1, 1, 0, 0, 0, 0, eur)
...