How to get the current timestamp in other timezones in Golang?

后端 未结 2 1310
太阳男子
太阳男子 2021-02-04 23:56

I need to get the current time in different time-zones.

Currently I know that we can do the following:

t := time.Now()
fmt.Println(\"Location:\", t.Loca         


        
2条回答
  •  后悔当初
    2021-02-05 00:13

    //init the loc
    loc, _ := time.LoadLocation("Asia/Shanghai")
    
    //set timezone,  
    now := time.Now().In(loc)
    

提交回复
热议问题