Hi.
Among other data, I get the date and time from a buffer and I need to compare it with the current date.
But even simulating the current date, when I do the conversion there is a very large difference between the date received via buffer and the current date, approximately 125 days
What am I doing wrong?
How can I do this using function?
[{"id":"13ed1b0a6338ba91","type":"inject","z":"b5bfdf7d38fd994f","name":"time date","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[\"0x12\",\"0x16\",\"0x12\",\"0x0c\",\"0x16\"]","payloadType":"bin","x":700,"y":1020,"wires":[["ceae1eaa6db92208"]]},{"id":"ceae1eaa6db92208","type":"function","z":"b5bfdf7d38fd994f","name":"function 4","func":"var yy;\nvar mm;\nvar dd;\nvar hh;\nvar min;\n\n//year\nif (msg.payload[4] < 10) {\n yy = \"0\" + msg.payload[4]// + \":00\"\n} else {\n\n yy = msg.payload[4]// + \":00\"\n}\n//month\nif (msg.payload[3] < 10) {\n mm = \"0\" + msg.payload[3]// + \":00\"\n} else {\n\n mm = msg.payload[3]// + \":00\"\n}\n//day\nif (msg.payload[2] < 10) {\n dd = \"0\" + msg.payload[2]// + \":00\"\n} else {\n\n dd = msg.payload[2]// + \":00\"\n}\n//hour\nif (msg.payload[0] < 10) {\n hh = \"0\" + msg.payload[0]// + \":00\"\n} else {\n\n hh = msg.payload[0]// + \":00\"\n}\n//minutes\nif (msg.payload[1] < 10) {\n min = \"0\" + msg.payload[1]// + \":00\"\n} else {\n\n min = msg.payload[1]// + \":00\"\n}\n//minutes\nif (msg.payload[1] < 10) {\n min = \"0\" + msg.payload[1]// + \":00\"\n} else {\n\n min = msg.payload[1]// + \":00\"\n}\n\n\nmsg.clock2 = (\n \"20\" + yy + \"-\" +\n mm + \"-\" +\n dd + \"T\" +\n hh + \":\" +\n min + \":00+0000\"\n)\n\nmsg.dif = (((Date.now() - 10798840) - (Date.parse(msg.clock2) - 0)) / 1000);\nmsg.buffer = Date.parse(msg.clock2);\nmsg.now = Date.now();\n\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":900,"y":1020,"wires":[["d7f23d72e1130986"]]},{"id":"d7f23d72e1130986","type":"debug","z":"b5bfdf7d38fd994f","name":"debug 11","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1100,"y":1020,"wires":[]}]