SQLITE as a Source: wrong unitstamp to date transformation

Hello,

I’m trying to visualize the trend data recorded by Codesys PLC.
It writes the trends to SQLITE file with UNIXTIMESTAMP as DataTime.

When I try to convert it in Grafana, the calculated Date Time is not correct.
the Online converter shows the right date-time for the same value.

please see the picture below
Unixtimestamp-SQLITE

Hi,

Is your Grafana timezone set correctly?

Good Luck

Hello,

It is set to CET, the PLC which created the sqlite file - too.

Hi,

Check if this works for you :

Good Luck

Hello,

no, it doesn’t work. I tried different metrics for data field (’/1000’ , ‘*1000’) but the retrieved date-time is not correct. Please look at the year values, it is weird and seems like a random one (actually it is March 2021)

Test2

in JS this function gives the correct value:

var unixTsToDate = function (UNIX_Timestamp){
var date = new Date(UNIX_Timestamp / 1000);
return date;
};

e.g. unixTsToDate (1615370972685000) = Wed Mar 10 2021 11:09:32 GMT+0100
and as you see on the screenshot in Grarfana it is:
2224-10-21 23:45:28
1718-04-24 21:16:46 (with 1000 divider)

Which Grafana version are you using ?

*v7.4.3 (010f20c1c8)

This topic was automatically closed after 365 days. New replies are no longer allowed.