How to append time to payload?
877dev opened this issue · comments
I seem to be missing something obvious. I have a true or false switch node, when "false" is outputted I want to set the payload message to "<time/date> Door is open".
As the input to the moment node is to be triggered by a "false" message from the switch node, I can't see how to get the time/date appended.
Any ideas?
Hi, thanks for raising. Often best to raise general questions in the Node-RED forum though as you tend to get a faster and possibly more complete response because lots of people will be looking at it.
In this case, if I've understood you correctly, you have two choices:
-
Use MomentJS's formatting. You can add text to the output format by escaping it with square brackets.
See here under "Escaping Characters" for details.
[today] dddd
-
Alternatively, add the timestamp to some field other than payload and then use a change node after the moment node to merge the timestamp with whatever other text you want.