# Fixing Date Countdown

**URL:** <https://forum.kirupa.com/t/fixing-date-countdown/317216>\
**Category:** flash\
**Created:** [December 14, 2010, 2:09am UTC](https://forum.kirupa.com/t/fixing-date-countdown/317216 "2010-12-14T02:09:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pherank](https://avatars.discourse-cdn.com/v4/letter/p/4af34b/32.png) [@Pherank](https://forum.kirupa.com/u/Pherank)\
**Post date:** [December 14, 2010, 2:09am UTC](https://forum.kirupa.com/t/fixing-date-countdown/317216/1 "2010-12-14T02:09:34Z")

</div>

I would like to get this date countdown working. Right now it is inaccurate in its count. It’s off by almost 30 days.

```auto

//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.
