Today I encountered an interesting problem with window.setInterval. When used with a sufficiently large delay (in this case the number of milliseconds in 30 days) it executes every second instead of every 30 days. Tested in latest Chrome and Firefox.
document.getElementById("first").innerHTML = new Date().toString();
document.getElementById("second").innerHTML = new Date().toString();
According to the
setTimeout documentation on the public wiki MDN there is indeed a maximum, though it doesn't seem "official" - the limitation is a signed 32 bit integer.
Maximum delay value
Browsers including Internet Explorer, Chrome, Safari, and Firefox store the delay as a 32-bit signed integer internally. This causes an integer overflow when using delays larger than 2147483647, resulting in the timeout being executed immediately.
The value of
2592000000 is indeed larger than
2147483647 thus causing the overflow.