Nodered function node code

I am running node red from hassio. I have a sensor in hassio that gives time of some events as payload in the format 2019-06-03T20:38:00. I want to use this sensor for automation but because of this format its not happening. i tried to use node-red-contrib-simpletime, but it gives wrong time. i would like to get advice to execute this. i,e Using the sensor payload which is a time format for calling a service from hassio at that time from the format.

Have you tried node-red-contrib-moment? It is highly configurable.

1 Like

Use the JS Date function & you can do what ever you need to...

var myDate = new Date("2019-06-03T20:38:00")

var y = myDate.getFullYear(); //2019
var h = myDate.getHours();//20


You need to post more info. What doesn't work? Screen shots? Debug output? Exact format of data you require etc etc.

1 Like

Actually it worked, my earlier post was approved late by node red forum..thats why i said it didnt. i am able to extract time in the format HH:mm from the input payoad.. But the second part is still confusing. i now have the time extracted, thanks to you all and at this time I have to call a service...mostly like an alarm...that can be set n the flow and not by conventional method of nodered editor..any ideas..?