How to calculate the week number for a given date in Go

1 Answer

0 votes
package main

import (
	"fmt"
	"time"
)

func main() {
	date := time.Date(2025, time.March, 15, 0, 0, 0, 0, time.UTC)

	// Get the ISO week number
	_, week := date.ISOWeek()

	fmt.Printf("The week number for %s is: %d\n", date.Format("2006-01-02"), week)
}



/*
run:

The week number for 2025-03-15 is: 11

*/

 



answered Mar 15, 2025 by avibootz

Related questions

1 answer 88 views
1 answer 237 views
1 answer 220 views
220 views asked Aug 26, 2020 by avibootz
1 answer 148 views
1 answer 97 views
...