This node generates a time stamp when it gets an input.
The incoming payload is saved and used on the second output.
The node generates a local time time stamp and presents it to the three outputs as:
1 - as text which can be used in a text file.
2 - as msg.topic
in the same format as output #1
3 - as text which is compatible to be used in a file name. (Striped :
from the output)
Yeah, it won't fix every need, but it could be handy.
Rather than having to constantly use the moment
node - which I used - and set the output style.
This is a simple addition to what the node does and how it can be used.
[{"id":"5828ee16.d65a","type":"subflow","name":"Time Stamp","info":"","category":"","in":[{"x":80,"y":100,"wires":[{"id":"38fcac0b.21d234"}]}],"out":[{"x":780,"y":100,"wires":[{"id":"ae0623ca.fcb5e","port":0}]},{"x":780,"y":150,"wires":[{"id":"e0f25625.f2aee8","port":0}]},{"x":780,"y":200,"wires":[{"id":"8897711f.686e08","port":0}]}],"env":[],"color":"#FF8888","outputLabels":["For logging use","msg.time","For filename use"],"icon":"node-red/timer.svg"},{"id":"ba266090.d5a6","type":"function","z":"5828ee16.d65a","name":"Time Stamp","func":"var d = new Date().toLocaleString();\nmsg.payload = d;\nreturn msg;","outputs":1,"noerr":0,"x":310,"y":100,"wires":[["ae0623ca.fcb5e"]]},{"id":"ae0623ca.fcb5e","type":"moment","z":"5828ee16.d65a","name":"","topic":"","input":"","inputType":"msg","inTz":"Australia/Sydney","adjAmount":0,"adjType":"days","adjDir":"add","format":"YYYY-DD-MM HH:mm:ss","locale":"en_AU","output":"","outputType":"msg","outTz":"Australia/Sydney","x":500,"y":100,"wires":[["8897711f.686e08","238422be.bf932e"]]},{"id":"8897711f.686e08","type":"string","z":"5828ee16.d65a","name":"","methods":[{"name":"replaceAll","params":[{"type":"str","value":":"},{"type":"str","value":""}]},{"name":"replaceAll","params":[{"type":"str","value":" "},{"type":"str","value":""}]}],"prop":"payload","propout":"payload","object":"msg","objectout":"msg","x":550,"y":200,"wires":[[]]},{"id":"238422be.bf932e","type":"change","z":"5828ee16.d65a","name":"TOPIC","rules":[{"t":"move","p":"payload","pt":"msg","to":"time","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":330,"y":150,"wires":[["e0f25625.f2aee8"]]},{"id":"38fcac0b.21d234","type":"change","z":"5828ee16.d65a","name":"Save","rules":[{"t":"set","p":"payload","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":170,"y":100,"wires":[["ba266090.d5a6"]]},{"id":"e0f25625.f2aee8","type":"change","z":"5828ee16.d65a","name":"Get","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":550,"y":150,"wires":[[]]}]