DEV Community

loading...

Discussion on: Get the number of days between two dates in Go

Collapse
alexyslozada profile image
Alexys Lozada
func daysBetween(a, b time.Time) float64 {
    if a.After(b) {
        a, b = b, a
    }
    return math.Ceil(b.Sub(a).Hours() / 24.0)
}