3.8 时区转换


package main

import (
	"fmt"
	"time"
)

func main() {
	eur, err := time.LoadLocation("Europe/Vienna")
	if err != nil {
		panic(err)
	}

	t := time.Date(2000, 1, 1, 0, 0, 0, 0, eur)
	fmt.Printf("Original Time: %v
", t)

	phx, err := time.LoadLocation("America/Phoenix")
	if err != nil {
		panic(err)
	}

	t2 := t.In(phx)
	fmt.Printf("Converted Time: %v
", t2)

}

/*
Original Time: 2000-01-01 00:00:00 +0100 CET
Converted Time: 1999-12-31 16:00:00 -0700 MST
*/

原文地址:https://www.cnblogs.com/zrdpy/p/8620873.html