Node-red-contrib-moment - how to add timestamp from incoming MQTT node?

Can anyone advise on this please. The issue is that unless I use a timestamp trigger node, the time does not set and it shows 00:00. The date shows correctly. The MQTT node sends either true or false.

No doubt I am misunderstanding something...

Why are you sending true or false to the moment node? It takes a date/time string or Javascript Date object as input.

1 Like

Hello again, I think that is where I am misunderstanding. How do I send a date/time string to the node other than using a trigger node?

I hope it is clear from my flow, that I want the mqtt event to trigger the message "Button pressed <date/time>".

No problem. The simplest thing to do is to change the input property in moment to something that doesn't exist. This works because the moment node should return the current date/time in that case as indicated in the help sidebar.

Great that is working thank you!

I did read the help believe it or not, I misunderstood and thought it meant sending an empty msg.payload to the node would result in date/time, whcih was not working.

Now I have it set as input from "msg.payload.fake" and it works as expected.

Thanks very much for your time :smile:

1 Like

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