Ah, well I just assumed time would not go backward. Anyways, I just finished working out a method that works for numbers of virtually any size (ex: 90006001002003007008.8765) which also works with numbers less than 1000:
Code:
<script type="text/javascript">
//Set the two dates
var millennium =new Date(1962, 9, 19) //Month is 0-11 in JavaScript
today=new Date()
//Get 1 day in milliseconds
var one_day=1000*60*60*24
function parseout3digitgroups(n, d){
d = d || ',';
n = n.toString(10).split('.');
n[0] = n[0].split('');
var nn = n[0].length, c = 0, r = '';
while(--nn > -1){
r = n[0][nn] + r;
if((++c) % 3 === 0 && nn){
r = d + r;
}
}
return r + (n[1]? '.' + n[1] : '');
}
//Calculate difference btw the two dates, and convert to days
var format_days_since = parseout3digitgroups(Math.ceil((today.getTime()-millennium.getTime())/(one_day)));
document.write(format_days_since + " days");
</script>
I will probably make this simpler later. But it might be about it - that is if you need it to be able to do real large and/or less than 1000 and/or anything in between.
Bookmarks