time.Time.In() Function in Golang with Examples Last Updated : 28 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 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 "loc" is nil then panic is returned. 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) In(loc *Location) Time Here, "t" is the stated time, and "loc" is the stated location which is a pointer to the location. Return value: It returns 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 "loc" is nil then panic is returned. Example 1: C // Golang program to illustrate the usage of // Time.In() function // Including main package package main // Importing fmt and time import "fmt" import "time" // Calling main func main() { // Defining t for In method t := time.Date(2019, 12, 13, 3, 23, 43, 02, time.UTC) // Defining loc parameter of In method loc := time.FixedZone("UTC", 6*54*44) // Calling In() method res := t.In(loc) // Prints output fmt.Printf("%v\n", res) } Output: 2019-12-13 07:21:19.000000002 +0357 UTC Example 2: C // Golang program to illustrate the usage of // Time.In() function // Including main package package main // Importing fmt and time import "fmt" import "time" // Calling main func main() { // Defining t for In method t := time.Date(2022, 23, 45, 36, 67, 88, 667, time.UTC) // Defining loc parameter of In method loc := time.FixedZone("UTC-6", -3*66*77) // Calling In() method res := t.In(loc) // Prints output fmt.Printf("%v\n", res) } Output: 2023-12-16 08:54:22.000000667 -0414 UTC-6 Here, the "t" stated in the above code has values that are outside usual range but they are normalized while conversion. Comment More infoAdvertise with us Next Article time.Time.In() Function in Golang with Examples N nidhi1352singh Follow Improve Article Tags : Go Language GoLang-time Similar Reads time.Time.Minute() Function in Golang With Examples In Go language, time packages supplies functionality for determining as well as viewing time. The Time.Minute() function in Go language is used to find the minute offset within the stated hour that is provided by "t" and the range is [0, 59]. Moreover, this function is defined under the time package 2 min read time.Time.String() Function in Golang With Examples In Go language, time packages supplies functionality for determining as well as viewing time. The Time.String() function in Go language is used to yield the time which is formatted with the help of the format string. Moreover, this function is defined under the time package. Here, you need to import 2 min read time.Time.Sub() Function in Golang With Examples In Go language, time packages supplies functionality for determining as well as viewing time. The Time.Sub() function in Go language is used to yield the duration obtained by performing the operation t-u. And if the output here surpasses the maximum or the minimum value that can be stored in a Durat 2 min read time.NewTimer() Function in Golang With Examples In Go language, time packages supplies functionality for determining as well as viewing time. The NewTimer() function in Go language is used to create a new Timer that will transmit the actual time on its channel at least after duration "d". Moreover, this function is defined under the time package. 2 min read time.Time.Month() Function in Golang With Examples In Go language, time packages supplies functionality for determining as well as viewing time. The Time.Month() function in Go language is used to find the month of the year as provided by t. Moreover, this function is defined under the time package. Here, you need to import the "time" package in ord 2 min read Like