I have two dates like this, I would like to compare only the dates, ignoring the time. Currently I have this:
package main
import (
"time"
//"fmt"
)
func main() {
a, _ := time.Parse(time.RFC3339, "2017-02-01T12:00:00+00:00")
b, _ := time.Parse(time.RFC3339, "2017-02-11T14:30:00+00:00")
x := b.Sub(a)
println(int(x.Hours()))
}
Which prints 242
. That is correct, but what I actually want to do is compare the dates like this:
a, _ := time.Parse(time.RFC3339, "2017-02-01T00:00:00+00:00")
b, _ := time.Parse(time.RFC3339, "2017-02-11T00:00:00+00:00")
Notice: minutes/hours/seconds have been set to zero - the diff will now be 240 hours.
I couldn't really figure out how to do this, is there a time.SetTime(0, 0, 0)
function in Go that I missed or what's the canonical way to reset the time for a date?