hi..
i want to have a countdown timer in my php page....which gives the following info..
12 days, 5 hours, 6 mins, 4 secs...
the difference between today and a date that is stored in a mysql table. i have written the following function in javascript and called the function on the page's body's onload... it now calculates the diff between the date from db and local time(system time...) what i want to do is to calculate the time diff between the date from db and the GMT...can anyone pls help me???
function getTime()
{
now = new Date();
y2k = new Date(document.timeForm.text1.value);
//y2k = new Date("Jan 1 2005 14:00:00");
days = (y2k - now) / 1000 / 60 / 60 / 24;
daysRound = Math.floor(days);
hours = (y2k - now) / 1000 / 60 / 60 - (24 daysRound);
hoursRound = Math.floor(hours);
minutes = (y2k - now) / 1000 /60 - (24 60 daysRound) - (60 hoursRound);
minutesRound = Math.floor(minutes);
seconds = (y2k - now) / 1000 - (24 60 60 daysRound) - (60 60 hoursRound) - (60 minutesRound);
secondsRound = Math.round(seconds);
sec = (secondsRound == 1) ? " second." : " seconds.";
min = (minutesRound == 1) ? " minute | " : " minutes | ";
hr = (hoursRound == 1) ? " hour | " : " hours | ";
dy = (daysRound == 1) ? " day | " : " days | ";
document.timeForm.timerdisp.value = daysRound + dy + hoursRound + hr + minutesRound + min + secondsRound + sec;
newtime = window.setTimeout("getTime();", 1000);
}
Thanks,
sumathi