A lightweight node-red node to provide and format date and time.
A Node-RED node that is extremely lightweight and which can be inserted in any running flow, and adds time and date payloads with various formatting options, which can be retreived and used later in the flow.
Run the following command in your Node-RED user directory - typically
npm install node-red-contrib-simpletime
Any existing payloads or topics being injected into simpletime will pass unaltered through the node.
In addition to any existing payloads, a number of additional payloads will be added, which can be utilised later in the flow.
The additional payloads added to the flow, and their typical content format are;
- msg.myrawdate: "2017-11-08T20:36:26.257Z"
- msg.myepoch: 1510173386257
- msg.mydate: "Wed Nov 08 2017"
- msg.myhour: "20"
- msg.myminute: "36"
- msg.myminutes: "36:26"
- msg.mysecond: "26"
- msg.mytime: "20:36"
- msg.mytimes: "20:36:26"
To introduce any of the messages into a flow, simply assign any, or any combination of the messages into a variable, such as;
var seconds = msg.myseconds; or to use in a ui_text node add via mustache
For more advanced timezone handling,
node-red-contrib-moment is recommended.