package main import ( "fmt" "time" ) func main() { now := time.Now() fmt.Println(now.Day()) }
package main import ( "fmt" "time" ) func main() { t := time.Date(2022, 5, 10, 14, 30, 0, 0, time.UTC) fmt.Println(t.Day()) }This code creates a new Time value representing May 10th, 2022 at 2:30 PM UTC, and then calls the Day() method on it to print the day of the month. The time package is a built-in package provided by Go, so it doesn't need to be installed separately.