Unix timestamp from json query

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
User avatar
WillemDH
Posts: 2320
Joined: Wed Mar 20, 2013 5:49 am
Location: Ghent
Contact:

Unix timestamp from json query

Post 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
Nagios XI 5.8.1
https://outsideit.net
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Unix timestamp from json query

Post 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.
Former Nagios employee
jomann
Development Lead
Posts: 611
Joined: Mon Apr 22, 2013 10:06 am
Location: Nagios Enterprises

Re: Unix timestamp from json query

Post 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.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
WillemDH
Posts: 2320
Joined: Wed Mar 20, 2013 5:49 am
Location: Ghent
Contact:

Re: Unix timestamp from json query

Post by WillemDH »

Ok, thanks for confirming. Thread can be closed. :)
Nagios XI 5.8.1
https://outsideit.net
Locked