Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
example go code to load/print a time in another TZ
package main
import (
const (
datelayout string = "2006-01-02 15:04:05"
func main() {
fmt.Printf("now in default TZ=%s\n", time.Now())
location, _ := time.LoadLocation("Asia/Tokyo")
fmt.Printf("loaded location=%s\n", location)
fmt.Printf("now in Asia/Tokyo=%s\n", time.Now().In(location))
// Expected Output:
// now in default TZ=2014-07-14 15:50:32.494723966 -0700 PDT
// loaded location=Asia/Tokyo
// now in Asia/Tokyo=2014-07-15 07:50:32.495017166 +0900 JST
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.