Skip to content
Home » Program to get the day of the specified date in Golang

Program to get the day of the specified date in Golang

Learn about Program to get the day of the specified date in Golang in the below code example. Also refer the comments in the code snippet to get a detailed view about what’s actually happening.

Program to get the day of the specified date in Golang

// Golang program to get the Weekday of the specified date

package main

import "fmt"
import "time"

func main() {
	date := time.Date(2022, 4, 25, 11, 7, 25, 0, time.UTC)

	fmt.Println("Weekday is: ", date.Weekday())
}

In the above program, we imported the fmt package, which contains the files of the fmt package, and then we can use a function related to the fmt package. Here, we created a date-time object using Date() function. Then we got the weekday of a specific date using Weekday() function

Hope above code works for you and Refer the below Related Codes to gain more insights. Happy coding and come back again.

Similar Codes :
Program to convert a date-time object into a string in Golang
How to compare two dates in Golang