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
+4.7k Golang : Configure crontab to poll every two minutes 8am to 6pm Monday to Friday
+5.1k Golang : Convert Chinese UTF8 characters to Pin Yin
+32.8k Golang : How to stream file to client(browser) or write to http.ResponseWriter?
+10.5k Golang : Change date format to yyyy-mm-dd
+3.1k Golang : PGX CopyFrom to insert rows into Postgres database
+11k Golang : Send data to /dev/null a.k.a blackhole with ioutil.Discard
+8.4k Golang : Accessing content anonymously with Tor
+30.5k Golang : Copy directory - including sub-directories and files
+11.5k Golang : Get terminal width and height example
+5.6k Golang : Calculate pivot points for a cross
+7.3k Python : Fix SyntaxError: Non-ASCII character in file, but no encoding declared
+5.7k Golang : Find the shortest line of text example