Trouble converting int64 to timestamp

I just trying to get year and month from a timestamp field in a jsong string downloaded from a url.
For example

package main

import (
“fmt”
“time”
)

func main() {
m1 := int64(1560207582311)
t1 := time.Unix(m1, 0)

m2 := int64(1532009163)
t2 := time.Unix(m2, 0)

fmt.Println(t1.Format(“2006-01-02”))
fmt.Println(t2.Format(“2006-01-02”))
}

But I got this :
51411-01-05 // m1
2018-07-19 // m2

m2 is taken from a sample in the web, and it woirks fine but m1 is from the json loaded from url.

Any hint ?

Regards,
Yamil

As you can see by the order of magnitude of the input, m1 is probably a timestamp in milliseconds or indeed a date that is 49000 years in the future.

1 Like

Thanks!!!

fmt.Println(time.UnixMilli(1560207582311))

yes!!!
I did not read time documentation clearly…
Thanks a lot!!!

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.