Skip to content

Instantly share code, notes, and snippets.

@karl-gustav
Created May 27, 2018 17:36
Show Gist options
  • Select an option

  • Save karl-gustav/04048436e3a45bec328a7abc521f676d to your computer and use it in GitHub Desktop.

Select an option

Save karl-gustav/04048436e3a45bec328a7abc521f676d to your computer and use it in GitHub Desktop.
Compare two datetimes in golang
package main
import (
"fmt"
"time"
)
func main() {
const layout = "2006-01-02T15:04:05"
time1 := time.Now()
time2 := time.Now()
if time1.Format(layout) == time2.Format(layout) {
fmt.Println("The time values are equal")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment