Golang time.Time.ISOWeek() function example
package time
Golang time.Time.ISOWeek() function usage example. Use in calculating the week number in a given year.
package main
import (
"fmt"
"time"
)
func main() {
now := time.Now()
fmt.Println("Today : ", now.Format(time.ANSIC))
year, week := now.ISOWeek()
fmt.Printf("The ISO 8601 year is %d and week is %d \n", year, week)
}
Sample output :
Today : Fri Aug 7 13:42:24 2015
The ISO 8601 year is 2015 and week is 32
Reference :
Advertisement
Something interesting
Tutorials
+32.8k Golang : How to check if a date is within certain range?
+17.7k Golang : Qt image viewer example
+6.8k Golang : Calculate BMI and risk category
+6.4k Golang : Map within a map example
+31.7k Golang : Convert an image file to []byte
+8.9k Golang : How to use Gorilla webtoolkit context package properly
+10.5k Golang : Allow Cross-Origin Resource Sharing request
+15.1k Golang : Get timezone offset from date or timestamp
+9.5k Golang : Quadratic example
+25.6k Golang : How to write CSV data to file
+20.9k Golang : Sort and reverse sort a slice of strings
+5.7k Cash Flow : 50 days to pay your credit card debt