Example to use Weekday and YearDay function
Weekday returns the day of the week specified by t. YearDay returns the day of the year specified by t, in the range [1,365] for non-leap years, and [1,366] in leap years.
Example
package main
import (
"fmt"
"time"
)
func main() {
t,_ := time.Parse("2006 01 02 15 04", "2015 11 11 16 50")
fmt.Println(t.YearDay()) // 315
fmt.Println(t.Weekday()) // Wednesday
t,_ = time.Parse("2006 01 02 15 04", "2011 01 01 0 00")
fmt.Println(t.YearDay())
fmt.Println(t.Weekday())
}
Output
315
Wednesday
1
Saturday
Most Helpful This Week
How to declare and access pointer variable?
Example: How to use ReadAtLeast from IO Package in Golang?
Find element in a slice and move it to first position?
How to check string contains uppercase lowercase character in Golang?
How to add Watermark or Merge two image?
Replace any non-alphanumeric character sequences with a dash using Regex