Skip to content

Instantly share code, notes, and snippets.

@nidhi-canopas
Last active February 27, 2022 20:12
Show Gist options
  • Select an option

  • Save nidhi-canopas/81c3358b646813b016512353881ef68f to your computer and use it in GitHub Desktop.

Select an option

Save nidhi-canopas/81c3358b646813b016512353881ef68f to your computer and use it in GitHub Desktop.
import (
"time"
"fmt"
)
func main() {
timeZone := "Asia/Kolkata" // timezone value
loc, _ := time.LoadLocation(timeZone)
currentTime = time.Now().In(loc)
fmt.Println("currentTime : ", currentTime)
}
output:
// for timezone = "Asia/Kolkata"
currentTime : 2022-02-09 10:42:39.164079505 +0530 IST
// for timezone = "Asia/Shanghai"
currentTime : 2022-02-09 13:14:33.986953939 +0800 CST
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment