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
Split URL and Get Parameters from URL
Closures Functions in Golang
Find element in a slice and move it to first position?
Convert Int data type to Int16 Int32 Int64
How to reads and decodes JSON values from an input stream?
How to rotate an image?
Golang download image from given URL
How to set, get, and list environment variables?
Sierpinski Carpet in Go Programming Language
What is GOPATH?