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:**

`// 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) ` `} ` |

*chevron_right*

*filter_none*

**Output:**

year: 2013 week: 15

**Example 2:**

`// 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) ` `} ` |

*chevron_right*

*filter_none*

**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.

## Recommended Posts:

- math.Lgamma() Function in Golang with Examples
- math.Float64bits() Function in Golang With Examples
- atomic.AddInt64() Function in Golang With Examples
- atomic.StoreInt64() Function in Golang With Examples
- reflect.FieldByIndex() Function in Golang with Examples
- string.Contains Function in Golang with Examples
- bits.Sub() Function in Golang with Examples
- io.PipeWriter.CloseWithError() Function in Golang with Examples
- time.Round() Function in Golang With Examples
- reflect.AppendSlice() Function in Golang with Examples
- reflect.ChanOf() Function in Golang with Examples
- flag.Bool() Function in Golang With Examples
- time.Sleep() Function in Golang With Examples
- time.Time.Year() Function in Golang with Examples
- reflect.DeepEqual() Function in Golang with Examples
- reflect.Indirect() Function in Golang with Examples
- reflect.CanAddr() Function in Golang with Examples
- reflect.CanInterface() Function in Golang with Examples
- reflect.CanSet() Function in Golang with Examples
- reflect.Cap() Function in Golang with Examples

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.