Time Zones
Work with locations.
Time Carries a Location
Every time.Time has an associated location (time zone). The same instant can be displayed differently depending on the zone.
package main
import (
"fmt"
"time"
)
func main() {
t := time.Date(2026, 5, 30, 12, 0, 0, 0, time.UTC)
fmt.Println(t.Location())
}UTC and Local
Two built-in locations are always available:
time.UTCfor Coordinated Universal Time.time.Localfor the machine's local zone.
package main
import (
"fmt"
"time"
)
func main() {
t := time.Date(2026, 5, 30, 12, 0, 0, 0, time.UTC)
fmt.Println(t.UTC().Hour())
}