I would like to get this date countdown working. Right now it is inaccurate in its count. It’s off by almost 30 days.
//Create a date object for 3/25/2011
//HOW TO ADJUST FOR TIMEZONE?
var newyear:Date = new Date(2011, 3, 25, 0, 0, 0, 0);
//Current date object
var now:Date = new Date();
// Conditional to snap to frame 3 if it is xmas or past xmas
if (now >= newyear) {
gotoAndStop(3);
}
// Set the difference between the two date and times in milliseconds
var timeDiff:Number = newyear.getTime() - now.getTime();
//Convert the timeDiff(which is in milliseconds) into regular seconds-minutes-hours-days
//The Math.floor is the closest rounded integer that is less than or equal to the decimal number
var seconds:Number = Math.floor(timeDiff / 1000);
var minutes:Number = Math.floor(seconds / 60);
var hours:Number = Math.floor(minutes / 60);
var days:Number = Math.floor(hours / 24);
// Set the remainder of the division vars above
hours %= 24;
minutes %= 60;
seconds %= 60;
// String all vars together for display
var timeRemaining:String = "Days= " + days + " Hours= " + hours + " Minutes= " + minutes + " Seconds= " + seconds;
// Display everything in their dynamic text fileds
timeString.text = timeRemaining;
now_txt.text = "Now = " + now;
newyear_txt.text = "03/25/2011 = " + newyear;
I’m also wondering if anyone knows how to add adjustment for timezone. I need to adjust by -4 hours from GMT.