time.Month.String() Function in Golang With Examples
In Go language, time packages supplies functionality for determining as well as viewing time. The Month.String() function in Go language is used to find the English name of the month. 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 (m Month) String() string
Here, “m” is the type Month.
Return Value: It returns a string which is the English name of the month.
Example 1:
package main
import "fmt"
import "time"
func main() {
var m = time .Month(2)
fmt.Println(m.String())
}
|
Output:
February
Example 2:
package main
import "fmt"
import "time"
func main() {
var m = time .Month(12)
fmt.Println(m.String())
}
|
Output:
December
Last Updated :
21 Apr, 2020
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...