I need a count up that increases by $30 million per day beginning Oct 1, 2013. My code below is based on a post here
code in head:
window.onload=function(){
var amount = document.getElementById('amount');
var start = new Date("October 1, 2013 00:00:00").getTime();
var current;
update();
function update() {
var current = (new Date().getTime() - start)/1000*147.22222222;
amount.innerText = formatMoney(current);
}
setInterval(update,1000);
function formatMoney(amount) {
var dollars = Math.floor(amount).toString().split('');
var cents = (Math.round((amount%1)*100)/100).toString().split('.')[1];
if(typeof cents == 'undefined'){
cents = '00';
}else if(cents.length == 1){
cents = cents + '0';
}
var str = '';
for(i=dollars.length-1; i>=0; i--){
str += dollars.splice(0,1);
if(i%3 == 0 && i != 0) str += ',';
}
return '$' + str;
}
}
code in body:
<div id='amount'></div>
Two things are wrong. It doesn't work in Firefox (neither does the code it's based on). And the total should be over $60 million by now but it's only around $30 million. Any help is appreciated.