package main import ( "fmt" "time" ) func main() { fmt.Println("==== Now ====") ptz(time.Now()) fmt.Println("==== 1996-11-14 00:00:00 +0800 ====") t1, _ := time.Parse(time.RFC3339, "1996-11-14T00:00:00+08:00") ptz(t1) fmt.Println("==== 1996-11-14 00:00:00 +0600 ====") t2, _ := time.Parse(time.RFC3339, "1996-11-14T00:00:00+06:00") ptz(t2) } func p(t time.Time) { fmt.Println(t.Year(), t.Month().String(), t.Day(), t.Hour(), t.Minute(), t.Second()) } func ptz(t time.Time) { t1 := t t2 := t1.Local() t3 := t1.UTC() l1 := t1.Location() l2 := t2.Location() l3 := t3.Location() fmt.Println("Location", l1, l2, l3) fmt.Println("Raw:") p(t1) fmt.Println("Local:") p(t2) fmt.Println("UTC:") p(t3) }