[Go] Add calendar days to a date

Created on November 30, 2026

You can use time.Time.AddDate to move a date forward by a specified number of calendar days. The three arguments are years, months, and days. This example adds one day to a fixed date.

package main

import (
    "fmt"
    "time"
)

func main() {
    start := time.Date(2021, time.July, 18, 11, 54, 34, 0, time.UTC)
    nextDay := start.AddDate(0, 0, 1)
    fmt.Println(nextDay.Format("2006-01-02"))
}
2021-07-19

Use time.Now() as the starting value to calculate a date relative to today. AddDate uses the time's location, so a calendar day can span a different number of hours when clocks change for daylight saving time.

Go