How to Get Current Weekday in Golang?
With the help of time.Now().Weekday()
function, we can get the weekday in Golang by importing time module.
Syntax: time.Now().Weekday()
Return: Return current weekday.
Example #1: In this example, we can see that by using time.Now().Weekday()
function, we are able to get the weekday.
package main
import "fmt"
import "time"
func main() {
dt := time .Now().Weekday()
fmt.Println(dt.String())
}
|
Output:
Monday
Example #2:
package main
import "fmt"
import "time"
func main() {
dt := time .Now().Weekday()
fmt.Println( int (dt))
}
|
Output:
1
Last Updated :
21 Apr, 2020
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...