In Go language, time packages supplies functionality for determining as well as viewing time. The Time.Year() function in Go language is used to find the year in which the specified “t” happens. 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) Year() int
Here, “t” is the stated time.
Return value: It returns the year in which the specified “t” occurs.
The stated year in the 't' specified is: 2019
The stated year in the 't' specified is: 2020
Here, the “t” stated above has values that are out of usual range but they are normalized while conversion.