Get Day Offset within Week in Go

Posted by yhuang
Public (Editable by Users)
Go
Edit
package main

import (
	"fmt"
	"time"
)

func main() {

	now := time.Now()

	// Day name.
	fmt.Println(now.Weekday())

	// Day integer.
	fmt.Println(int(now.Weekday()))

	// Compare with enum.
	fmt.Println(now.Weekday() == time.Monday)
}