Skip to content
Home » How to print tomorrow’s date in Golang

How to print tomorrow’s date in Golang

Learn about How to print tomorrow’s date in Golang in the below code example. Also refer the comments in the code snippet to get a detailed view about what’s actually happening.

How to print tomorrow’s date in Golang

// Golang program to print tomorrow's date

package main

import "fmt"
import "time"

func main() {

	today := time.Now()
	tomorrow := today.AddDate(0, 0, 1)

	fmt.Printf("Today    : %02d-%02d-%04d\n", today.Day(), today.Month(), today.Year())
	fmt.Printf("Tomorrow : %02d-%02d-%04d", tomorrow.Day(), tomorrow.Month(), tomorrow.Year())
}

In the above program, we imported the fmt package, which contains the files of the fmt package, and then we can use a function related to the fmt package. Here, we got today’s date using the Now() function and add 1 day into today’s date using the AddDate() function, and print tomorrow’s date

Hope above code works for you and Refer the below Related Codes to gain more insights. Happy coding and come back again.

Similar Codes :
How to print yesterday date in Golang
How to demonstrate the hours() function in Golang