Page 1 of 1

Unix timestamp from json query

Posted: Thu Mar 12, 2015 6:57 am
by WillemDH
Hello,

When I query alertlist from Nagios XI with json query, all the timestamp looks like this:

1426080059000

Unix time is actually like this? 1426080059. When I query this to show the recent alerts in some listview, can I safely divide these timestamps by 1000? Why does Nagios multiply the timestamps by 1000?

Grtz

Willem

Re: Unix timestamp from json query

Posted: Thu Mar 12, 2015 9:12 am
by tmcdonald
I believe that is to accommodate milliseconds should they ever be used in the future, but just in case it is actually a bug I will ask the devs.

Update: From what I understand, I was correct. It has to do with how Javascript handles the timestamp - it seems to need milliseconds.

Re: Unix timestamp from json query

Posted: Thu Mar 12, 2015 10:08 am
by jomann
Like Trevor said: Javascript uses milliseconds for timestamps instead of just seconds. To answer if it safe to divide them by 1000, yes it is just fine.

Re: Unix timestamp from json query

Posted: Thu Mar 12, 2015 11:51 am
by WillemDH
Ok, thanks for confirming. Thread can be closed. :)