[Go] Get the day of the week

Created on November 28, 2026

The Weekday() method in the time package returns the day of the week as a time.Weekday value. Converting that value to an int gives you a number from 0 to 6. Sunday is 0, and Saturday is 6.

import (
    "fmt"
    "time"
)

func main() {
    weekDay := time.Now().Weekday()
    fmt.Println(int(weekDay))
}

Running the example on a Sunday produces the following output.

0
Go