Timestamp conversion to date totally off

I have an inject node I run periodically. I take msg.timestamp and try to convert it to human readable form

var a = new Date();
msg.payload = { "Time": a.toLocaleTimeString(msg.timestamp*1000)};
return msg

And I get all kinds of times, sometimes even the right one, seemingly without a pattern. The node injects every ten minutes, and the times I get are not even progressing all the time, but seem totally random.
Yes, the Raspberry the server is running on has the correct timezone, and the msg.timestamp of the processing function node has the correct timestamp all the time.

I just don't get it. Where can a simple inject - process go so wrong???


var a = new Date(msg.timestamp);
msg.payload = { "Time": a.toLocaleTimeString('en-US')}; 
return msg

Basically, always check mdn

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