Open In App

time.Weekday.String() Function in Golang With Examples

In Go language, time packages supplies functionality for determining as well as viewing time. The Weekday.String() function in Go language is used to find the English name of the day. 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 (d Weekday) String() string

Here, “d” is the type Weekday.

Return value: It returns a string which is the English name of the day.



Example:




// Golang program to illustrate the usage of
// Weekday.String() function
  
// Including main package
package main
  
// Importing fmt and time
import "fmt"
import "time"
  
// Calling main
func main() {
  
    // Calling time.Weekday
    // with its parameter
    // of type int
    var d = time.Weekday(0)
    var e = time.Weekday(1)
    var f = time.Weekday(2)
    var g = time.Weekday(3)
    var h = time.Weekday(4)
    var i = time.Weekday(5)
    var j = time.Weekday(6)
  
    // Prints the English 
    // name of the day
    fmt.Println(d.String())
    fmt.Println(e.String())
    fmt.Println(f.String())
    fmt.Println(g.String())
    fmt.Println(h.String())
    fmt.Println(i.String())
    fmt.Println(j.String())
}

Output:

Sunday
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
Article Tags :