import "time" func main() { loc, _ := time.LoadLocation("") // "" is a shorthand for local time zone current_time := time.Now().In(loc) fmt.Println(current_time) }
import "time" func main() { // Define the time zone to convert from and to loc, _ := time.LoadLocation("America/New_York") target_loc, _ := time.LoadLocation("Europe/London") // Create a time object to convert t := time.Date(2021, time.July, 10, 15, 0, 0, 0, loc) // Convert the time to the target time zone and print it converted_time := t.In(target_loc) fmt.Println(converted_time) }In both examples, we are using the "time" package library to perform operations on time zones.