Suppose the following two dates. The date is the same, but the time is different.
t1, _ := time.Parse("2006-01-02 15:04:05", "2016-01-01 12:12:12.0")
t2, _ := time.Parse("2006-01-02 15:04:05", "2016-01-01 18:19:20.0")
I would compare them with help Format(), but I'm not sure if this is the best way, especially when different time zones are playing.
if t1.Format("2006-01-02") == t2.Format("2006-01-02") {
}
Is this a good approach, or am I missing something?
Kiril source
share