gpt-4o-mini-2024-07-18· OpenAI
WildChat-4.8M (AI2)
in golang get current time, in utc timezone and Poland timezone
- User
in golang get current time, in utc timezone and Poland timezone
- Assistant
In Go, you can get the current time in different time zones using the
timepackage. Here's how to get the current time in both UTC and the Poland timezone:gopackage main import ( "fmt" "time" ) func main() { // Get the current time in UTC currentTimeUTC := time.Now().UTC() fmt.Println("Current time in UTC:", currentTimeUTC) // Load the Poland timezone polandLocation, err := time.LoadLocation("Europe/Warsaw") if err != nil { fmt.Println("Error loading Poland timezone:", err) return } // Get the current time in Poland timezone currentTimePoland := time.Now().In(polandLocation) fmt.Println("Current time in Poland:", currentTimePoland) }