0
How to 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)
0
How to 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)
0
You must use the method Sub
:
fmt.Println(d2.Sub(d1))
// 24h0m0s
Playground: https://play.golang.org/p/TEk9bDU0Wz8.
Browser other questions tagged date golang
You are not signed in. Login or sign up in order to post.