time.Until() Function in Golang With Examples Last Updated : 21 Apr, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report In Go language, time packages supplies functionality for determining as well as viewing time. The Until() function in Go language holds time value t and is used to evaluate the duration until the time t. 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 Until(t Time) Duration Here, t is the time value. Note: This method is shortcut for t.Sub(time.Now()). Return value: It returns the duration until t. Example 1: C // Golang program to illustrate the usage of // Until() function // Including main package package main // Importing fmt and time import ( "fmt" "time" ) // Calling main func main() { // Defining time value // of Until method t := time.Now() // Prints duration until t fmt.Println("Duration until t:", time.Until(t)) } Output: Duration until t: -230ns // Can be different at different run times Here, duration until t is printed. So, it can be different at different run times. Example 2: C // Golang program to illustrate the usage of // Until() function // Including main package package main // Importing fmt and time import ( "fmt" "time" ) // Calling main func main() { // Defining time value // of Until method t := time.Now() // Calling Until method with its // parameter Duration := time.Until(t) // Prints duration until // t in nanoseconds fmt.Println("duration until t in nanoseconds: ", Duration.Nanoseconds()) } Output: duration until t in nanoseconds: -340 // Can be different at different run times Comment More infoAdvertise with us Next Article time.Unix() Function in Golang with Examples N nidhi1352singh Follow Improve Article Tags : Go Language GoLang-time Similar Reads time.Unix() Function in Golang with Examples In Go language, time packages supplies functionality for determining as well as viewing time. The Unix() function in Go language is used to yield the local time which is related to the stated Unix time from January 1, 1970, in UTC. Moreover, this function is defined under the time package. Here, you 2 min read time.Truncate() Function in Golang With Examples In Go language, time packages supply functionality for determining as well as viewing time. The Truncate() function in Go language is used to find the outcome of rounding the stated duration âdâ towards zero to a multiple of âmâ duration. Moreover, this function is defined under the time package. He 2 min read 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.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.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.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 Like