Learn about How to print date and time according to the specified location in Golang in the below code example. Also refer the comments in the code snippet to get a detailed view about what’s actually happening.
Contents
How to print date and time according to the specified location in Golang
// Golang program to print date and time
// according to the specified location
package main
import "fmt"
import "time"
func main() {
loc, error := time.LoadLocation("America/Los_Angeles")
if error != nil {
fmt.Println("Unable to load location")
}
ttime := time.Now()
fmt.Println(ttime.In(loc))
}
Hope above code works for you and Refer the below Related Codes to gain more insights. Happy coding and come back again.
Similar Codes :
How to print all months using predefined constants in Golang
How to iterate map elements using the range in Golang