Input a timestamp (default is the current timestamp) in milliseconds. The node will output an object of Hours, Minutes, mSeconds, Day, Month and Year.
-
-
Save mathcoll/ba071f83d91d2b065074 to your computer and use it in GitHub Desktop.
Convert timestamp to array hours, minutes, day, month, year
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[{"id":"4b27b7b.36083c8","type":"inject","name":"Force","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":226,"y":684,"z":"995dcaed.11032","wires":[["f7b2e05e.f958f8"]]},{"id":"2f5ae7e2.12b908","type":"debug","name":"output","active":true,"console":"false","complete":"true","x":818,"y":612,"z":"995dcaed.11032","wires":[]},{"id":"47a4278c.65ce68","type":"function","name":"timeConvert","func":"if ( !msg.timestamp ) msg.timestamp = Math.round(+new Date());\n\nvar dt = new Date(msg.timestamp);\nvar msg = {\n\t'month':\tdt.getMonth() + 1,\n\t'day':\t\tdt.getDate(),\n\t'year':\t\tdt.getFullYear(),\n\t'hours':\tdt.getHours(),\n\t'mins':\t\tdt.getMinutes(),\n\t'msecs':\tdt.getMilliseconds()\n}\n\nreturn msg;","outputs":1,"x":622,"y":612,"z":"995dcaed.11032","wires":[["2f5ae7e2.12b908"]]},{"id":"f7b2e05e.f958f8","type":"function","name":"set timestamp","func":"msg.timestamp=1376763133 * 1000;\nreturn msg;","outputs":1,"x":410,"y":684,"z":"995dcaed.11032","wires":[["47a4278c.65ce68"]]},{"id":"3bde431b.451a3c","type":"inject","name":"Force","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":226,"y":612,"z":"995dcaed.11032","wires":[["47a4278c.65ce68"]]}] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is good. I changed the repetition every second and the write to the global variable.