time.Time.UTC() Function in Golang with Examples Last Updated : 19 Apr, 2020 Comments Improve Suggest changes Like Article Like Report In Go language, time packages supplies functionality for determining as well as viewing time. The Time.UTC() function in Go language is used to yield "t" with the location that is set to UTC. Moreover, this function is defined under the time package. Here, you need to import the "time" package in order to use these functions. Syntax: func (t Time) UTC() Time Here, "t" is the stated time in UTC. Return Value: It returns t with the location that is set to UTC. Example 1: C // Golang program to illustrate the usage of // Time.UTC() function // Including main package package main // Importing fmt and time import ( "fmt" "time" ) // Calling main func main() { // Defining t for UTC method t := time.Date(2020, 11, 14, 11, 30, 32, 0, time.UTC) // Calling UTC method utc := t.UTC() // Prints output fmt.Printf("%v\n", utc) } Output: 2020-11-15 21:23:32 +0000 UTC Example 2: C // Golang program to illustrate the usage of // Time.UTC() function // Including main package package main // Importing fmt and time import ( "fmt" "time" ) // Calling main func main() { // Defining t for UTC method t := time.Date(2020, 23, 40, 56, 70, 0, 0, time.UTC) // Calling UTC method utc := t.UTC() // Prints output fmt.Printf("%v\n", utc) } Output: 2021-12-12 09:10:00 +0000 UTC Here, the time "t" stated in the above code have values that are out of usual range but they are normalized while conversion. Comment More infoAdvertise with us Next Article time.Time.UTC() Function in Golang with Examples N nidhi1352singh Follow Improve Article Tags : Go Language GoLang-time Similar Reads time.Time.Unix() Function in Golang with Examples In Go language, time packages supplies functionality for determining as well as viewing time. The Time.Unix() function in Go language is used to yield "t" as a Unix time that is the number of seconds passed from January 1, 1970, in UTC and the output here doesn't rely upon the location connected wit 2 min read time.Time.Truncate() Function in Golang with Examples In Go language, time packages supplies functionality for determining as well as viewing time. The Time.Truncate() function in Go language is used to find the output of rounding the stated time "t" to the closest multiple of the given duration "d" from the zero time. Moreover, this function is define 2 min read time.Time.In() Function in Golang with Examples In Go language, time packages supplies functionality for determining as well as viewing time. The In() function in Go language is used to find a copy of the stated "t" that represents the identical time instant, but along with the copy's location data that is set to "loc" for display uses. And if "l 2 min read time.Time.UnixNano() Function in Golang with Examples In Go language, time packages supply functionality for determining as well as viewing time. The Time.UnixNano() function in Go language is used to yield "t" as a Unix time that is the number of seconds passed from January 1, 1970, in UTC and the output here doesn't rely upon the location connected w 2 min read time.Time.Add() Function in Golang with Examples In Go language, time packages supplies functionality for determining as well as viewing time. The Time.Add() function in Go language is used to add the stated time and duration. Moreover, this function is defined under the time package. Here, you need to import the "time" package in order to use the 2 min read Like