Why now.getTime === stopTime.getTime() works,
but not now === stopTime?
[{"id":"9d15a9187c914833","type":"tab","label":"Flow 12","disabled":false,"info":"","env":[]},{"id":"c43a8169fed4b72e","type":"junction","z":"9d15a9187c914833","x":300,"y":180,"wires":[["29eb42608a865bce"]]},{"id":"29eb42608a865bce","type":"function","z":"9d15a9187c914833","name":"function 60 ","func":"const now = new Date();\nnow.setSeconds(0)\nnow.setMilliseconds(0)\n\n// Set start a copple of minutes ahead before deploy\nlet start = 55\nlet stop = start + 2\n\nconst startTime = new Date(now)\nconst stopTime = new Date(now)\nstartTime.setMinutes(start)\nstopTime.setMinutes(stop)\n\nnode.warn(now.getTime())\n\nif (now >= startTime && now <= stopTime) {\n\n if (now < stopTime) {\n node.warn('now < stoptime');\n }\n \n node.warn('0 ' + now)\n node.warn('1 ' + startTime)\n node.warn('2 ' + stopTime)\n\n //Why does this not work?\n if(now === stopTime) {\n node.warn('now === stopTime')\n }\n\n // But this does\n if (now.getTime() === stopTime.getTime()) {\n node.warn('now.getTime() === stopTime.genTime')\n }\n}\n\n\n\n","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":430,"y":180,"wires":[["51a892843386397a"]]},{"id":"51a892843386397a","type":"debug","z":"9d15a9187c914833","name":"debug 2593","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":650,"y":179,"wires":[]},{"id":"394dedca39d49512","type":"inject","z":"9d15a9187c914833","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"60","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":170,"y":179,"wires":[["c43a8169fed4b72e"]]}]
const now = new Date();
now.setSeconds(0)
now.setMilliseconds(0)
// Set start a copple of minutes ahead before deploy
let start = 55
let stop = start + 2
const startTime = new Date(now)
const stopTime = new Date(now)
startTime.setMinutes(start)
stopTime.setMinutes(stop)
node.warn(now.getTime())
if (now >= startTime && now <= stopTime) {
if (now < stopTime) {
node.warn('now < stoptime');
}
node.warn('0 ' + now)
node.warn('1 ' + startTime)
node.warn('2 ' + stopTime)
//Why does this not work?
if(now === stopTime) {
node.warn('now === stopTime')
}
// But this does
if (now.getTime() === stopTime.getTime()) {
node.warn('now.getTime() === stopTime.genTime')
}
}