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

**URL:** <https://discourse.nodered.org/t/node-red-contrib-moment-how-to-add-timestamp-from-incoming-mqtt-node/22873>\
**Category:** General\
**Created:** [9 March 2020 18:04 UTC](https://discourse.nodered.org/t/node-red-contrib-moment-how-to-add-timestamp-from-incoming-mqtt-node/22873 "2020-03-09T18:04:14Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![877](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/877/32/8207_2.png) [@877](https://discourse.nodered.org/u/877)\
**Post date:** [9 March 2020 18:04 UTC](https://discourse.nodered.org/t/node-red-contrib-moment-how-to-add-timestamp-from-incoming-mqtt-node/22873/1 "2020-03-09T18:04:15Z")

</div>

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...

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/8/28cae42d1670df47c95f85fc3e14251c21b4e244.png)

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [9 March 2020 18:07 UTC](https://discourse.nodered.org/t/node-red-contrib-moment-how-to-add-timestamp-from-incoming-mqtt-node/22873/2 "2020-03-09T18:07:43Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![877](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/877/32/8207_2.png) [@877](https://discourse.nodered.org/u/877)\
**Post date:** [9 March 2020 18:09 UTC](https://discourse.nodered.org/t/node-red-contrib-moment-how-to-add-timestamp-from-incoming-mqtt-node/22873/3 "2020-03-09T18:09:10Z")

</div>

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\>".

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [9 March 2020 18:18 UTC](https://discourse.nodered.org/t/node-red-contrib-moment-how-to-add-timestamp-from-incoming-mqtt-node/22873/4 "2020-03-09T18:18:09Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![877](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/877/32/8207_2.png) [@877](https://discourse.nodered.org/u/877)\
**Post date:** [9 March 2020 18:22 UTC](https://discourse.nodered.org/t/node-red-contrib-moment-how-to-add-timestamp-from-incoming-mqtt-node/22873/5 "2020-03-09T18:22:05Z")

</div>

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 😄

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [23 March 2020 18:22 UTC](https://discourse.nodered.org/t/node-red-contrib-moment-how-to-add-timestamp-from-incoming-mqtt-node/22873/6 "2020-03-23T18:22:08Z")

</div>

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