Skip to content

Instantly share code, notes, and snippets.

@franklinsales
Created April 20, 2017 21:19
Show Gist options
  • Save franklinsales/fcd5b6c26b7408680e20f8413293d123 to your computer and use it in GitHub Desktop.
Save franklinsales/fcd5b6c26b7408680e20f8413293d123 to your computer and use it in GitHub Desktop.
Go example using time.Time.Add()
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