Storage Write file node insert timestamp

I am a complete beginner in node-red and MQTT. I have a Pi zero 2 W as MQTT broker and node-red platform, and several temperature sensors that send data to the broker. For one of them I attached a write file node which when edited I added only the full path to the file. The file contains just temperature values, text as:
How do I write the time to receive the message in front of each temperature value?

There are may ways. Here is an example using the template node. It uses a timestamp, but you could convert that to a human readable if you wished.


thank you for response.
Now I heave data:
What format is that time ?

it is a timestamp in milliseconds since 1/1/1970 at 00:00 hours.

1 Like

I find on forum another way, I use a change node with $now() expression. I find also how to format the output data of time, so mai function is>


a temperature value of 55.1 Celsius is printing:
The only problem is the timezone is wrong, My place is GMT+2, so real time is 15:39.
How to insert time zone parameter in $now expression ?

LE find it, excuse me for rushing


You should store all times as UTC which is what the timestamp and $now() output. I would not bother formatting $now, as both the ISO output of time and the timestamp in milliseconds are both good formats for future processing.

When you store as a UTC time, you can then when displaying format for your timezone.

So my advice is to use the milliseconds (1519211811670) or the IS0 ("2022-01-30T12:31:19.000Z"), as you will find it causes less issue further down the road.

1 Like

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