# Node Red time setting

**URL:** https://discourse.nodered.org/t/node-red-time-setting/19463
**Category:** General
**Created:** [22 December 2019 14:31 UTC](https://discourse.nodered.org/t/node-red-time-setting/19463 "2019-12-22T14:31:29Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![ajocius](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ajocius/32/19024_2.png) [@ajocius](https://discourse.nodered.org/u/ajocius)
#### Post date: [22 December 2019 14:31 UTC](https://discourse.nodered.org/t/node-red-time-setting/19463/1 "2019-12-22T14:31:29Z")

</div>

I have one hour difference between local time and the one I get ![Time1](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/8/844402588de820adbc6fdaebca03211f562c3da6.png)

I have set timezone to Europe/Oslo  
I have also added line

> process.env.TZ = "Europe/Oslo";  
> into settings.js file

I see that RaspberryPi shows correct time. I use node-red to receive message from mqtt server. Message only contains temp and humidity values, no time in message payload. I then show temp and humidity with time on a dashboard and can see that time is always by 1 hour different.

---

<div class="post-metadata">

### Author: ![ajocius](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ajocius/32/19024_2.png) [@ajocius](https://discourse.nodered.org/u/ajocius)
#### Post date: [22 December 2019 14:48 UTC](https://discourse.nodered.org/t/node-red-time-setting/19463/2 "2019-12-22T14:48:40Z")

</div>

This could also be driven by the function I use to get time:

```auto
msg.payload=new Date().toISOString()
return msg;

```

Is there any way to make it output correct time?

---

<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: [22 December 2019 15:30 UTC](https://discourse.nodered.org/t/node-red-time-setting/19463/3 "2019-12-22T15:30:05Z")

</div>

That is the correct time, the Z means that it is the time in UTC. If you lookup the JavaScript date functions you will find methods that will give you a string to display it in the local timezone.

---

<div class="post-metadata">

### Author: ![ajocius](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ajocius/32/19024_2.png) [@ajocius](https://discourse.nodered.org/u/ajocius)
#### Post date: [22 December 2019 15:44 UTC](https://discourse.nodered.org/t/node-red-time-setting/19463/4 "2019-12-22T15:44:18Z")

</div>

> [@Colin](#):
>
> JavaScript date functions

thank you for advice!

---

<div class="post-metadata">

### Author: ![ajocius](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ajocius/32/19024_2.png) [@ajocius](https://discourse.nodered.org/u/ajocius)
#### Post date: [22 December 2019 15:57 UTC](https://discourse.nodered.org/t/node-red-time-setting/19463/5 "2019-12-22T15:57:31Z")

</div>

have redone code based to following :

> var d = new Date();  
> msg.payload=d  
> return msg;

And then added debug node and text box on dashboard where msg.payload is used for both.  
 ![gauge](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/4/491218324065e29148de7aaff3f341305260bf1e.png)  
Debug window shows data as I want it to be:

> 12/22/2019, 4:51:03 PM[node: c9fd5127.9a9dd](http://ajocius.mooo.com:7360/#)IG\_back\_DHT22 : msg.payload : Date
> 
> "Sun Dec 22 2019 16:51:04 GMT+0100 (CET)"

However dashboard still shows value with Z at the end and with one hour diff.  
 ![dashboard](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/3/30cad0be70e27ed5faf84219074551b2f186cf0b.png)  
How this can be when same msg.payload is used for both. How can I get correct time on my dashboard?

---

<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: [22 December 2019 21:48 UTC](https://discourse.nodered.org/t/node-red-time-setting/19463/6 "2019-12-22T21:48:29Z")

</div>

As I said before those are both correct.15:51 UTC is the same time as 16:51 GMT+1. What you are asking is how to display that time in one format rather than the other.  
One way to do that would be to feed it into a node-red-contrib-moment node to generate the particular format you want.

---

<div class="post-metadata">

### Author: ![afelix](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/afelix/32/9743_2.png) [@afelix](https://discourse.nodered.org/u/afelix)
#### Post date: [22 December 2019 23:01 UTC](https://discourse.nodered.org/t/node-red-time-setting/19463/7 "2019-12-22T23:01:59Z")

</div>

Take a look at [https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global\_Objects/Date/toLocaleString](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleString) too, it might do what you’re looking for.
