UNIX timestamp 2 hours out of sync
-
Hi There
I have been struggling with the UNIX timestamp conversion a while now. I finally got it working but now for whatever reason the time stamp DCI value netxms pulls is 2 hours behind exactly.
I did a online converter of the timestamp as well and i get the same results.
More info:
I poll dci value using File.Time.Modify parameter. I then use a script to convert from UNIX time. However, DCI value being polled is 2 hours behind the actual value.Please assist.
Regards
-
How are you collecting the timestamp and how are you transforming it?
It sounds like your transformation happends in UTC, whereas your timezone is +2.You can see how NXSL time-related functions work in this example script:
// current time in Unix time timeVar = time(); // lets convert to time object in UTC timezone timeGM = gmtime(timeVar); // lets convert to time object in our local timezone timeLocal = localtime(timeVar); // lets print all of them // remember this is in UTC timezone println(timeGM->year . "-" . 1 + timeGM->mon . "-" . timeGM->mday . " " . timeGM->hour . ":" . timeGM->min); // this one will be in our local time, because we are using localtime() function println(timeLocal->year . "-" . 1 + timeLocal->mon . "-" . timeLocal->mday . " " . timeLocal->hour . ":" . timeLocal->min); // this one should be the same, since strftime() function works in localtime println(strftime("%Y-%m-%d %H:%M - timezone %Z - offset from UTC - %z", timeVar)); -
Thanx for the speedy reply.
I actually found what my issue was. i was using the gmtime function and just changed to localtime and it works 100% now

I used basics here but nonetheless it works

day = localtime($1)->mday; mon = localtime($1)->mon+1; year = localtime($1)->year; hour = localtime($1)->hour; min = localtime($1)->min; return day."-".mon."-".year."/".hour.":".min;I could have just added a variable t = ($1) to make it even easier.
Thanx for the advice and putting me in the right direction.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login