time.Time.ISOWeek() 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 ISOWeek() function in Go language is used to find the ISO 8601 year and week number in which the stated "t" happened. Where the range of the week is from 1 to 53. 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) ISOWeek() (year, week int) Here, "t" is the stated time, "year" and "week" are the two values that are returned as output in this method. Note: Jan 01 to Jan 03 of any year say 'n' will most probably belong to the week 52 or 53 of year 'n-1' and Dec 29 to Dec 31 might be a part of the week 1 of year 'n+1'. Return value: It returns the ISO 8601 year and week number in which the stated "t" happened. Example 1: C // Golang program to illustrate the usage of // Time.ISOWeek() function // Including main package package main // Importing fmt and time import "fmt" import "time" // Calling main func main() { // Defining t for ISOWeek method t := time.Date(2013, 4, 11, 12, 37, 33, 0, time.UTC) // Calling ISOWeek() method year, week := t.ISOWeek() // Prints the year fmt.Printf("year: %v\n", year) // Prints the week number fmt.Printf("week: %d\n", week) } Output: year: 2013 week: 15 Example 2: C // Golang program to illustrate the usage of // Time.ISOWeek() function // Including main package package main // Importing fmt and time import "fmt" import "time" // Calling main func main() { // Defining t for ISOWeek method t := time.Date(2022, 35, 37, 29, 99, 70, 6388, time.UTC) // Calling ISOWeek() method year, week := t.ISOWeek() // Prints the year fmt.Printf("year: %v\n", year) // Prints the week number fmt.Printf("week: %d\n", week) } Output: year: 2024 week: 49 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.ISOWeek() Function in Golang with Examples N nidhi1352singh Follow Improve Article Tags : Go Language GoLang-time Similar Reads 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.IsZero() Function in Golang With Examples In Go language, time packages supplies functionality for determining as well as viewing time. The Time.IsZero() function in Go language is used to check if the stated time "t" implies zero time instant or not i.e, January 1, year 1, 00:00:00 UTC. Moreover, this function is defined under the time pac 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.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.Second() Function in Golang with Examples In Go language, time packages supplies functionality for determining as well as viewing time. The Time.Second() function in Go language is used to find the second offset within the minute as provided by "t" and the range is [0, 59]. Moreover, this function is defined under the time package. Here, yo 2 min read Like