Original post

Hi

I playing with a rest api, using golang http.Client. One of the responses I get is a timestamp in UNIX time.
The input is 13 numbers long, I cant convert it to time using time.Unix, It only takes 10 digits.

I have solved it this way:
https://play.golang.org/p/foCLoASas18

  1. Convert the input to a string.
    2 Only take 10 chars.
  2. Convert it back to ints.
  3. Convert to unix time.

Any better ideas to solve this?

Hi

I think I came up with a simpler solutino:

https://play.golang.org/p/kLRPVS85wa4

Divede the input with 1000, cast it to a int64, then convert from Unix time to time.Time

// Micke

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