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
Find element in a slice and move it to first position?
Find capacity of Channel, Pointer and Slice
Regular Expression to get a string between parentheses in Golang
How to collect information about garbage collection?
Get Hours, Days, Minutes and Seconds difference between two dates [Future and Past]
Generate a Keygen of 256 bits
Data encryption with AES-GCM
How to extract text from between html tag using Regular Expressions in Golang?
Split a character string based on change of character
Closures Functions in Golang