The period between two dates

0

How do I get a period between two dates?

d1, _ := time.Parse(time.RFC3339, "2018-10-27T00:00:00Z")
d2, _ := time.Parse(time.RFC3339, "2018-10-28T00:00:00Z")
// Não funciona.
fmt.Println(d2 - d1)
    
asked by anonymous 28.10.2018 / 13:32

1 answer

0

You should use the Sub method:

fmt.Println(d2.Sub(d1))
// 24h0m0s

Playground: link .

    
28.10.2018 / 13:32