Convert non-UTC timestamp to UTC

Yes I was able to solve the issue like I described in post 15 Convert non-UTC timestamp to UTC .

1 Like

Its only just occured to me but why not just ignore the time from the device and replace it with the message is processed by Node-RED?

It might be different by a few mins but is that important?

2 Likes

Yes that is an option but the main reason I wanted to use the timestamp of the device is that the JSON is updated on a irregular basis, mainly based on on how much the measurements vary. Sometimes the JSON does not change for 20 minutes, sometimes it is every minute. So I read the JSON every minute and I write the data into my database without any condition. By taking the timestamp of the device, I overwrite an existing record if the JSON timestamp has not changed. If I take the time of when the message is processed, I will have a record every minute. That will work but I will have much more data in the database.

You could add a condition to not write to the database if the incoming timestamp is the same as the last processed one

That is correct so that is a 2nd solution :wink: .

1 Like

That would also have the advantage that the timestamps would be correct even if the clock in the device is off, as it appears it is from the examples you have shown.