Skip to content

Instantly share code, notes, and snippets.

@Infocatcher
Created June 16, 2014 09:29
Show Gist options
  • Save Infocatcher/6b3f9d79ef66d14fabc1 to your computer and use it in GitHub Desktop.
Save Infocatcher/6b3f9d79ef66d14fabc1 to your computer and use it in GitHub Desktop.
Max JavaScript date
// Result: 0x1eb208c2dc0000 (Sat, 13 Sep 275760 00:00:00 GMT)
var time = 0;
var add = 0x10000;
for(;;) {
var newTime = time + add;
if(newTime == time) {
alert("Looke like max integer: 0x" + time.toString(16));
break;
}
var date = new Date(newTime);
if(date.getTime()) {
add = Math.floor(add*10);
}
else {
if(add > 1) {
add = Math.floor(add/2);
if(add >= 1)
continue;
}
alert("Max: 0x" + time.toString(16) + "\n" + new Date(time).toUTCString());
break;
}
time = newTime;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment