# Wrong timezone in Node-RED

**URL:** <https://discourse.nodered.org/t/wrong-timezone-in-node-red/67545>\
**Category:** General\
**Created:** [10 September 2022 10:15 UTC](https://discourse.nodered.org/t/wrong-timezone-in-node-red/67545 "2022-09-10T10:15:46Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![network\_potato](https://avatars.discourse-cdn.com/v4/letter/n/59ef9b/32.png) [@network\_potato](https://discourse.nodered.org/u/network_potato)\
**Post date:** [10 September 2022 10:15 UTC](https://discourse.nodered.org/t/wrong-timezone-in-node-red/67545/1 "2022-09-10T10:15:46Z")

</div>

It seems my Node-RED is 2 hours off.

This is the output of an inject node directly connected to a debug node, notice the timestamp of the debug node is correct, but the string inside is 2 hours off:

![debug](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/6/367e9a2bd22c86a8d48c247321e2344d47775575.jpeg)

I run Node-RED in Docker, with the environment variable "TZ" set correctly, and this is the output of the `date` command both inside the Docker container and on the host machine:

Docker:  
 ![docker](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/a/6ae5da70595680a5ac5085c68ec9a258e80039c6.jpeg)

Host:  
 ![host](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/2/128e3797d2e97b915b5a176ee7097cfde46a6b9e.jpeg)

How do I fix this?

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [10 September 2022 10:26 UTC](https://discourse.nodered.org/t/wrong-timezone-in-node-red/67545/2 "2022-09-10T10:26:04Z")

</div>

You are receiving the timestamp in UTC you can format it for your time zone.  
e.g.

```auto
[{"id":"451d767d.1de568","type":"inject","z":"bf9e1e33.030598","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":180,"y":4180,"wires":[["24f0cea0.ec617a"]]},{"id":"24f0cea0.ec617a","type":"change","z":"bf9e1e33.030598","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$moment($$.payload).tz(\"Europe/Berlin\").format()","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":320,"y":4220,"wires":[["2d2a3654.07f15a"]]},{"id":"2d2a3654.07f15a","type":"debug","z":"bf9e1e33.030598","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":500,"y":4180,"wires":[]}]

```

Jsonata expression

```auto
$moment($$.payload).tz("Europe/Berlin").format()

```

Or you can use "CET" as timezone in expression

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [10 September 2022 10:26 UTC](https://discourse.nodered.org/t/wrong-timezone-in-node-red/67545/3 "2022-09-10T10:26:22Z")

</div>

The string denotes `Z` which is Zulu time = UTC

---

<div class="post-metadata">

**Author:** ![network\_potato](https://avatars.discourse-cdn.com/v4/letter/n/59ef9b/32.png) [@network\_potato](https://discourse.nodered.org/u/network_potato)\
**Post date:** [10 September 2022 11:13 UTC](https://discourse.nodered.org/t/wrong-timezone-in-node-red/67545/4 "2022-09-10T11:13:11Z")

</div>

Thank you!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [9 November 2022 11:13 UTC](https://discourse.nodered.org/t/wrong-timezone-in-node-red/67545/5 "2022-11-09T11:13:41Z")

</div>

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