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.Location(), ":Time:", t)
utc, err := time.LoadLocation("America/New_York")
if err != nil {
fmt.Println("err: ", err.Error())
}
fmt.Println("Location:", utc, ":Time:", t.In(utc))
The LoadLocation name is taken to be a location name corresponding to a file in the IANA Time Zone database, such as "America/New_York".
Is there a simpler way to get the current time, if the country name, or the GMT offset is given e.g +530 for India?
Edit: I would also want to support Day light savings.