Created
April 20, 2017 21:19
-
-
Save franklinsales/fcd5b6c26b7408680e20f8413293d123 to your computer and use it in GitHub Desktop.
Go example using time.Time.Add()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"time" | |
) | |
func main() { | |
datetimeFormat := "2006-01-02 15:04:05" | |
now := time.Now() | |
fmt.Printf("Type of now: %T \n", now) | |
actualDate := now.Format(datetimeFormat) | |
fmt.Printf("Type of actualDate: %T \n", actualDate) | |
fmt.Println(actualDate) | |
moreOneHour := time.Hour * 1 | |
fmt.Printf("\nType of moreOneHour: %T \n", moreOneHour) | |
nextDate := now.Add(moreOneHour).Format(datetimeFormat) | |
fmt.Printf("Type of nextDate: %T \n", nextDate) | |
fmt.Println(nextDate) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment