I'm trying to pull a date from an online database and compare it with today's date. I can get the data ok but for some reason in the function node the date format is being changed. I'm in the UK and use dd/mm/yyyy but for some reason its being changed to mm/dd/yyyy and doing the comparison. I can't find out where I have gone wrong.
[{"id":"740c0c0471c21759","type":"tab","label":"Flow 5","disabled":false,"info":"","env":[]},{"id":"1eedac72d8918492","type":"inject","z":"740c0c0471c21759","name":"Test","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":90,"y":240,"wires":[["99f8b2657ee7f1f5","6e7bd3e5b29aaf66"]]},{"id":"6e7bd3e5b29aaf66","type":"moment","z":"740c0c0471c21759","name":"Current date","topic":"","input":"payload","inputType":"msg","inTz":"Europe/London","adjAmount":"0","adjType":"hours","adjDir":"subtract","format":"L","locale":"","output":"currentdate","outputType":"flow","outTz":"Europe/London","x":250,"y":300,"wires":[["d12a0c1ac4222f47"]]},{"id":"d12a0c1ac4222f47","type":"debug","z":"740c0c0471c21759","name":"Current date test","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":430,"y":300,"wires":[]},{"id":"99f8b2657ee7f1f5","type":"http request","z":"740c0c0471c21759","name":"notification","method":"GET","ret":"txt","paytoqs":"ignore","url":"https://api.nationalgrideso.com/dataset/e5277fca-2a2b-4836-933b-f24a676b9ed8/resource/94b4d470-a54e-41d7-ae6e-be158db9b9d4/download/dfs-industry-notification.csv","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":250,"y":240,"wires":[["0a807f10f81fdd79"]]},{"id":"0a807f10f81fdd79","type":"csv","z":"740c0c0471c21759","name":"","sep":",","hdrin":true,"hdrout":"none","multi":"one","ret":"\\n","temp":"","skip":"0","strings":true,"include_empty_strings":false,"include_null_values":false,"x":390,"y":240,"wires":[["7158b144a59e9ff4"]]},{"id":"7158b144a59e9ff4","type":"switch","z":"740c0c0471c21759","name":"Limit","property":"parts.index","propertyType":"msg","rules":[{"t":"lt","v":"20","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":510,"y":240,"wires":[["03257b94a4246f1b"]]},{"id":"03257b94a4246f1b","type":"delay","z":"740c0c0471c21759","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":650,"y":240,"wires":[["270d730b187e557a"]]},{"id":"270d730b187e557a","type":"function","z":"740c0c0471c21759","name":"Combine date and time","func":"//msg.payload[\"Delivery Date\"];\n\nvar date = msg.payload[\"Requirement For\"];\n\n//var date = msg.payload[\"Requirement For\"];\nvar time = 0;\n\n//var response = (date + \" \" + time);\n\nvar response = date;\n\nmsg.payload.checked = response\nreturn msg;","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":850,"y":240,"wires":[["6623113f9da4aeeb","5b554ed4f9bf3b3f"]]},{"id":"5b554ed4f9bf3b3f","type":"debug","z":"740c0c0471c21759","name":"debug 280","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload.checked","targetType":"msg","statusVal":"","statusType":"auto","x":1070,"y":200,"wires":[]},{"id":"6623113f9da4aeeb","type":"moment","z":"740c0c0471c21759","name":"","topic":"","input":"payload.checked","inputType":"msg","inTz":"Europe/London","adjAmount":"0","adjType":"milliseconds","adjDir":"subtract","format":"L","locale":"en-GB","output":"ssdate","outputType":"flow","outTz":"Europe/London","x":1100,"y":240,"wires":[["ccf68115a65cc533","f290611db45bb03e"]]},{"id":"ccf68115a65cc533","type":"function","z":"740c0c0471c21759","name":"ssdate","func":"var ssdate = flow.get(\"ssdate\");\n\nmsg.payload = ssdate;\nreturn msg;","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":1290,"y":200,"wires":[["789998c614adef14"]]},{"id":"789998c614adef14","type":"debug","z":"740c0c0471c21759","name":"ssdate","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1410,"y":200,"wires":[]},{"id":"f290611db45bb03e","type":"function","z":"740c0c0471c21759","name":"Check Nat Grid date","func":"\nvar date1 = new Date(flow.get(\"ssdate\")).valueOf();\nvar date2 = new Date(flow.get(\"currentdate\")).valueOf();\nvar date3 = new Date(flow.get(\"ssdate\"));\n\n\nmsg.date11 = new Date(flow.get(\"ssdate\"));\nmsg.date1 = date1;\nmsg.date21 = new Date(flow.get(\"currentdate\"));\nmsg.date2 = date2;\n\nif (date1 == date2 || date1 > date2)\n{\nflow.set(\"Initial\", \"YES\");\n// @ts-ignore\nnode.status({ fill: 'green', text: date3});\n}\nelse\n{\nflow.set(\"Initial\", \"NO\");\n}\nreturn msg;\n","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":1340,"y":240,"wires":[["b078bc3b5270cadd"]]},{"id":"b078bc3b5270cadd","type":"switch","z":"740c0c0471c21759","name":"Check Initial","property":"Initial","propertyType":"flow","rules":[{"t":"cont","v":"YES","vt":"str"},{"t":"cont","v":"NO","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":1530,"y":240,"wires":[["6d7380a83a05438b"],[]]},{"id":"dc3a83c89cb11b29","type":"debug","z":"740c0c0471c21759","name":"RESULT","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1800,"y":240,"wires":[]},{"id":"6d7380a83a05438b","type":"function","z":"740c0c0471c21759","name":"Initial","func":"var ssdate = flow.get(\"Initial\");\n\nmsg.payload = ssdate;\nreturn msg;","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":1670,"y":240,"wires":[["dc3a83c89cb11b29"]]}]