Используйте все, что time.Location
имеет смысл для вашего приложения. Например,
package main
import (
"fmt"
"time"
"cloud.google.com/go/civil"
)
func main() {
now := time.Now().Round(0)
fmt.Println(now, " : time Now")
d := civil.DateTimeOf(now)
fmt.Println(d, " : civil DateTime")
t := d.In(time.UTC)
fmt.Println(t, " : time UTC")
t = d.In(time.Local)
fmt.Println(t, " : time Local")
pacific, err := time.LoadLocation("America/Los_Angeles")
if err != nil {
fmt.Println(err)
return
}
t = d.In(pacific)
fmt.Println(t, " : time Pacific")
}
Выход:
2018-07-03 12:46:15.728611385 -0400 EDT : time Now
2018-07-03T12:46:15.728611385 : civil DateTime
2018-07-03 12:46:15.728611385 +0000 UTC : time UTC
2018-07-03 12:46:15.728611385 -0400 EDT : time Local
2018-07-03 12:46:15.728611385 -0700 PDT : time Pacific