Hi Ira,
The issue you're facing is due to the float precision. In other words, when you save a float it's going to lose its precision, so next time you read it, it won't look the same. And when you're saving a timestamp in storage it gets saved as a float, that's why you're seeing this issue.
I modified your script adding the .toString() function to save it as a string in storage, then used the Number() function to convert it back to numeric after it's read so you can perform your operations, and it worked:
curTime = new Date().getTime();
if (storage.global.LastInstance != null) {
console.info("not null");
oldTime = Number(storage.global.LastInstance);
if (curTime > (Number(storage.global.LastInstance) + 10000)) {
console.info("OK to proceed");
} else {
console.info("too soon");
}
console.info("oldTime " + oldTime / 1000);
console.info("Last Instance " + Number(storage.global.LastInstance) / 1000);
console.info("curTime " + curTime / 1000);
} else {
console.info("it is null");
}
storage.global.LastInstance = curTime.toString();
console.info("Last Instance " + Number(storage.global.LastInstance) / 1000);
return 0;
I hope this helps.
Julien
It definitely does help. Thanks for the answer and taking the time to provide a solution.