Greetings, I have the following code:
The problem is that its based on the local timezone of whoever loads it. I was wondering if there was some way of enforcing a timezone so every user gets the same countdown to the same "dateFuture".
Thanks in advance
Code:
<SCRIPT TYPE="text/javascript" LANGUAGE="JavaScript">
<!-- //start
// NOTE: the month entered must be one less than current month. ie; 0=January, 11=December
// NOTE: the hour is in 24 hour format. 0=12am, 15=3pm etc
// example: dateFuture = new Date(2003,03,26,14,15,00) = April 26, 2003 - 2:15:00 pm
// format: dateFuture = new Date(year,month-1,day,hour,min,sec)
dateFuture = new Date(2007,7,9,13,5,46);
// TESTING: comment out the line below to print out the "dateFuture" for testing purposes
//document.write(dateFuture +"<br />");
//###################################
//nothing beyond this point
function GetCount()
{
dateNow = new Date(); //grab current date
if (dateNow.getTime() < dateFuture.getTime()) //Checking if date set for counter has expired
{
//It hasn't expired so we get the counter started
amount = dateFuture.getTime() - dateNow.getTime(); //calc milliseconds between Now and Then
delete dateNow;
days=0;hours=0;mins=0;secs=0;out="";
amount = Math.floor(amount/1000);//kill the "milliseconds" so just secs
days=Math.floor(amount/86400);//days
amount=amount%86400;
hours=Math.floor(amount/3600);//hours
amount=amount%3600;
mins=Math.floor(amount/60);//minutes
amount=amount%60;
secs=Math.floor(amount);//seconds
if(days != 0){out += ((days<10)?"0":"") + days + ":";}
if(days != 0 || hours != 0){out += ((hours<10)?"0":"") + hours + ":";}
if(days != 0 || hours != 0 || mins != 0){out += ((mins<10)?"0":"") + mins + ":";}
out += ((secs<10)?"0":"") + secs + " EST";
document.getElementById('countbox').innerHTML=out;
setTimeout("GetCount()", 1000);
}
else
{
amount = dateFuture.getTime() - dateNow.getTime(); //calc milliseconds between dates
amount = Math.floor(amount/1000);//turn the milliseconds into seconds
amount = Math.floor(amount/60);//turn the seconds into minutes
delete dateNow;
if (amount < 0 && amount > -40) //Checking if the match is still 'going' (matches take 40 mins in average)
{
document.getElementById('countbox').innerHTML="Match Is Now Live";
}
else
{
document.getElementById('countbox').innerHTML="No Matches Are Currently Scheduled";
}
}
}
//-->
</script>
The problem is that its based on the local timezone of whoever loads it. I was wondering if there was some way of enforcing a timezone so every user gets the same countdown to the same "dateFuture".
Thanks in advance