Skip to content

A lightweight node-red node to provide and format date and time.

License

Notifications You must be signed in to change notification settings

Meloman-zz/node-red-contrib-simpletime

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

56 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

node-red-contrib-simpletime

NPM version NPM downloads per month NPM downloads total MIT License JavaScript Style Guide

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.

Install

Run the following command in your Node-RED user directory - typically ~/.node-red

npm install node-red-contrib-simpletime

Usage

Inputs

Any existing payloads or topics being injected into simpletime will pass unaltered through the node.

Outputs

In addition to any existing payloads, a number of additional payloads will be added, which can be utilised later in the flow.

By default, all the additional properties will be added to the message but this can be altered in the node configuration, using checkboxes

Details

The additional payloads added to the flow, and their typical content format are;

  • msg.mydate: "Tue Sep 11 2018"
  • msg.myymd: "2018-09-11"
  • msg.myyear: "2018"
  • msg.mymonth: "Sep"
  • msg.mymonthn: "09"
  • msg.mydom: "11"
  • msg.mydoy: "86"
  • msg.myday: "Tue"
  • msg.myhourpm: "7"
  • msg.myhour: "19"
  • msg.mytime: "19:51"
  • msg.mytimes: "19:51:17"
  • msg.myminute: "51"
  • msg.myminutes: "51:17"
  • msg.mysecond: "17"
  • msg.mymillis: "985"
  • msg.myepoch: "1536691877064"
  • msg.myrawdate: "2018-09-11T18:51:17.064Z"
  • msg.mypm: "PM"
  • msg.mysql: "2018-09-11 18:51:17"

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 {{mytimes}}
More advanced date formats can also be constructed, such as {{mytime}}hrs - {{mydom}}/{{mymonth}} to get "20:10hrs - 11/Sep", or {{myhourpm}}:{{myminute}}{{mypm}} to get "8.10PM"

For more advanced timezone handling, node-red-contrib-moment is recommended.

About

A lightweight node-red node to provide and format date and time.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • HTML 74.9%
  • JavaScript 25.1%