Population Counter script not working

Hi, I am having so much trouble tring to get a population counter script to work. I haven't used JavaScript before. This script was done by a friend but it doesn't work. Can you please have a look and suggest any changes to the script so it will work? I have already sspent three days on it and now I am desperate..

Thanks if you can help


var basisDate = new Date(2009,4,24,05,46,36).getTime(); // 24 May 2009 at 05:46:36 (Canberra Time)
var basisPop = 21769052; // population as at that time

function ozPop() {
var now = new Date();
var now = new Date().getTime();
var diff = (now - basisDate)/60000; // minutes
var newPop = parseInt((diff/1.5) + basisPop); // increase by 1 every 1.5 minutes
newPop = newPop.toString();
newPop = addCommas(newPop); // format with commas
msg = "The population of Australia as of this moment is estimated to be:- ";
document.getElementById("AustPop").innerHTML = msg + newPop;

window.setTimeout("ozPop()",30000); // update each half minute

function addCommas(nStr) {
nStr = nStr.replace(/[^0-9.]/g,"");
var rgx = /(d+)(d{3})/;
while (rgx.test(nStr)) {
nStr = nStr.replace(rgx, '$1,$2');
return nStr;

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!