Standard library / time

time.Time.ISOWeek()

Return ISO week-numbering year and week; year can differ from calendar year around January 1. Expected stdout: '2020 53\n'.

Formal Syntax & Structure

go syntaxgo
func (t Time) ISOWeek() (year, week int)

Return Value

(year, week int)

Return ISO week-numbering year and week; year can differ from calendar year around January 1.

Working Example

Example Snippetgo
package main
import (  "fmt"  "time")
func main() { y, w := time.Date(2021, 1, 1, 0, 0, 0, 0, time.UTC).ISOWeek(); fmt.Println(y, w) }
Go Reference