I want to check difference between given date and now. I want to use exactly the code below and it works fine in chrome. but the console log says something else in Firefox.
Why? and how to fix this?
// input your custom Date below
const date = new Date('2020-6-23 14:22:00 GMT+0430'); // Set End Time Here!
const dif = (date.getTime() / 1000) - ((new Date().getTime())/1000);
const end = Math.max(0, dif);
console.log(date, dif, end);
"GMT" does not belong in that string. The string should be ISO 8601 compliant, if you want to be sure that it gets parsed correctly.
To align it with the ISO standard:
+04:30
.const date = new Date('2020-06-23T14:22:00+04:30');
// Now also output it in the Iranian timezone:
console.log(date.toLocaleString("en", { timeZone: "Iran" } ));
BTW: GMT is an ambiguous term anyway. UTC is a more exact defined term.