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

后端 未结 2 1315
太阳男子
太阳男子 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:12

    No, that is the best way. You can create your custom Location using FixedZone and use that custom location.

    FixedZone returns a Location that always uses the given zone name and offset (seconds east of UTC).

提交回复
热议问题