Basically you want:
t1_raw := "2009-11-10 23:00:00 +0000 UTC m=+0.000000001"
format := "2006-01-02 15:04:05 -0700 MST"
// for simplicity t1_raw[:29] discards time's monotonic delta
// i.e. the " m=+0.000000001" suffix
t1, err := time.Parse(format, t1_raw[:29])
if err != nil {
log.Fatal(err)
}
log.Println("Duration ->", t2.Sub(t1))
If you really want the monotonic delta included, that number would have to be parsed manually and the delta applied to t1
.
Playground version.
Note: playground version will show a duration of zero - as the playground's clock starts on Nov 11 2009
- the seminal birthdate of go
.