package main
import (
"fmt"
"time"
)
func main() {
today := time.Now()
fmt.Println("today:", today.Format("02/01/2006"))
fmt.Println("Add 5 Days")
date1 := today.AddDate(0, 0, 5)
fmt.Println("date 1:", date1.Format("02/01/2006"))
fmt.Println("Add 4 Months")
date2 := today.AddDate(0, 4, 0)
fmt.Println("date 2:", date2.Format("02/01/2006"))
fmt.Println("Add 3 Years")
date3 := today.AddDate(3, 0, 0)
fmt.Println("date 3:", date3.Format("02/01/2006"))
fmt.Println("Sub 6 Days")
date4 := today.AddDate(0, 0, -6)
fmt.Println("date 4:", date4.Format("02/01/2006"))
fmt.Println("Sub 3 Months")
date5 := today.AddDate(0, -3, 0)
fmt.Println("date 5:", date5.Format("02/01/2006"))
fmt.Println("Sub 2 Years")
date6 := today.AddDate(-2, 0, 0)
fmt.Println("date 6:", date6.Format("02/01/2006"))
}
today: 29/11/2021
Add 5 Days
date 1: 04/12/2021
Add 4 Months
date 2: 29/03/2022
Add 3 Years
date 3: 29/11/2024
Sub 6 Days
date 4: 23/11/2021
Sub 3 Months
date 5: 29/08/2021
Sub 2 Years
date 6: 29/11/2019