TotallyInformation / node-red-contrib-moment

Node-Red Node that produces formatted Date/Time output using the Moment.JS library. Timezone, dst and locale aware.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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?

Setting up like this I get the date passed through but not the time for some reason...

image

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:

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

    image

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

Hi @TotallyInformation

Thank you, although that is also useful I don't think I explained myself clearly.
The issue is that unless I use a timestamp trigger node, the time does not set and it shows 00:00. The date is correct.

I've posted over on node red as you suggested HERE

Many thanks
877dev