Date.toISOString throws undefined error, sometimes

Here's some really simple JavaScript:


     var dispDate = new Date();

     dispDate.setHours( dispDate.getHours() + 7 ); // after five o'clock is tomorrow's list

     dispDateStr = dispDate.toISOString().substr( 0, 10 ).split("-").join("");


Each day that I call the script that this is in, and the code gives me an Exception: can't find function toISOString() for [today's date].

 If I open the file and make (any) small change, then change it back, the error goes away!

 What is going on?


Please sign in to leave a comment.