Finding the difference between two dates is not an unusual task. For this operation, the Go standard package time, respectively the Time type, provides supporting methods.
Finding the difference between two dates
How to do it...
- Open the console and create the folder chapter04/recipe07.
- Navigate to the directory.
- Create the diff.go file with the following content:
package main
import (
"fmt"
"time"
)
func main() {
l, err := time.LoadLocation("Europe/Vienna")
if err != nil {
panic(err)
}
t := time.Date(2000, 1, 1, 0, 0, 0, 0, l)
t2 := time.Date(2000, 1, 3, 0, 0, 0, 0, l)
fmt.Printf...