# Convert non-UTC timestamp to UTC

**URL:** <https://discourse.nodered.org/t/convert-non-utc-timestamp-to-utc/16092>\
**Category:** General\
**Created:** [30 September 2019 13:21 UTC](https://discourse.nodered.org/t/convert-non-utc-timestamp-to-utc/16092 "2019-09-30T13:21:59Z")\
**Posts on this page:** 6\
**Page:** 2

<div class="post-metadata">

**Author:** ![mifrey](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mifrey/32/12642_2.png) [@mifrey](https://discourse.nodered.org/u/mifrey)\
**Post date:** [2 October 2019 15:31 UTC](https://discourse.nodered.org/t/convert-non-utc-timestamp-to-utc/16092/21 "2019-10-02T15:31:20Z")

</div>

Yes I was able to solve the issue like I described in post 15 [Convert non-UTC timestamp to UTC](https://discourse.nodered.org/t/convert-non-utc-timestamp-to-utc/16092/15) .

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [2 October 2019 16:34 UTC](https://discourse.nodered.org/t/convert-non-utc-timestamp-to-utc/16092/22 "2019-10-02T16:34:23Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![mifrey](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mifrey/32/12642_2.png) [@mifrey](https://discourse.nodered.org/u/mifrey)\
**Post date:** [2 October 2019 20:26 UTC](https://discourse.nodered.org/t/convert-non-utc-timestamp-to-utc/16092/23 "2019-10-02T20:26:37Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [2 October 2019 20:52 UTC](https://discourse.nodered.org/t/convert-non-utc-timestamp-to-utc/16092/24 "2019-10-02T20:52:59Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![mifrey](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mifrey/32/12642_2.png) [@mifrey](https://discourse.nodered.org/u/mifrey)\
**Post date:** [2 October 2019 21:19 UTC](https://discourse.nodered.org/t/convert-non-utc-timestamp-to-utc/16092/25 "2019-10-02T21:19:40Z")

</div>

That is correct so that is a 2nd solution 😉 .

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [3 October 2019 06:13 UTC](https://discourse.nodered.org/t/convert-non-utc-timestamp-to-utc/16092/26 "2019-10-03T06:13:20Z")

</div>

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.

[Previous page](https://discourse.nodered.org/t/convert-non-utc-timestamp-to-utc/16092.md?page=1)
