[Go] View a time.Time in a different time zone

Created on November 30, 2026

Time.In returns a new time.Time for the same instant in the location you supply. This example prints the zone for a UTC time and again after converting it to Tokyo time.

package main

import (
    "fmt"
    "time"
)

func main() {
    t, err := time.ParseInLocation("2006-01-02 15:04:05", "2022-09-01 00:00:00", time.UTC)
    if err != nil {
        panic(err)
    }
    zone, _ := t.Zone()
    fmt.Println(zone)

    tokyo, err := time.LoadLocation("Asia/Tokyo")
    if err != nil {
        panic(err)
    }
    zone, _ = t.In(tokyo).Zone()
    fmt.Println(zone)
}
UTC
JST
Go