NR & Home Assistant : TZ problem

I am new to Node-Red in Home Assistant.
I am in France and I would like to have the dates in the format of the country, just like the hours (without AM / PM ...).
I added this line in the settings.js file:

process.env.TZ = "Europe / Paris"

But it does not work.
What should I do ?
Thank you

Welcome to the forum. Where do you want to see the timestamps in local time?

Hello Colin!
Thank you for your welcome :slight_smile:
I would like to see the timestamps in local time in the status of the nodes but especially in the result of the following function:

thank you very much


Node function :

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

Log :
Here I would like to see: 02/17/2021 20:35:44

Unless the developer of that node provided a method of updating the status you cannot modify it. You can format a string and display whatever you want beneath a function node or debug node only.

OK for the status of the node ... too bad!
And for the toLocaleString () function, any idea?
Thank you

You could use the moment nodes or the JSONata node or a function node.

I would favour a function node. There are thousands of examples around the net. Example tons of ideas in this thread.

Ok, alright.
I found someone on the forum talking about the function-npm node. It allows me to use moment () and get at least the hour in HH: MM: SS.
is that not a problem?

there is a contrib node called moment that "just works" - no need to code it or npm import moment.

But as i said, i dont use it (too heavy) just concatenate the parts of the data in a function - its not difficult!

or use JSONata.

For the moment, I prefer to use Javascript, I find it more understandable than JSONata which I sometimes have trouble understanding ...
In any case, thank you!

Same here. JSONata has limited reach and there is an order of magnitude of JavaScript Devs who can help out compared to JSONata.

You might also find node-red-contrib-simple-time useful. It does many of the simple things that node-red-contrib-moment does but does not have the overheads of the moment module.

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