# Countdown to a specific hour?

**URL:** <https://forum.kirupa.com/t/countdown-to-a-specific-hour/209144>\
**Category:** flash\
**Created:** [December 6, 2006, 11:15am UTC](https://forum.kirupa.com/t/countdown-to-a-specific-hour/209144 "2006-12-06T11:15:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![gameboyuk](https://avatars.discourse-cdn.com/v4/letter/g/50afbb/32.png) [@gameboyuk](https://forum.kirupa.com/u/gameboyuk)\
**Post date:** [December 6, 2006, 11:15am UTC](https://forum.kirupa.com/t/countdown-to-a-specific-hour/209144/1 "2006-12-06T11:15:05Z")

</div>

I have used a countdown window to the opening of a new restaurant.

\_[http://www.wheelhousefalkirk.com/](http://www.wheelhousefalkirk.com/)

The timer counts down to midnight but the restaurant opens at 10 am on the 18th.

Is there a way to countdown to a specific time?

Here’s the Action script I’m using…

> this.onEnterFrame = function() {

```
var today:Date = new Date ();
var currentYear = today.getFullYear();
var currentTime = today.getTime();

var targetDate:Date = new Date(currentYear,11,18);
var targetTime = targetDate.getTime();

var timeLeft = targetTime - currentTime;

var sec = Math.floor(timeLeft/1000);
var min = Math.floor(sec/60);
var hrs = Math.floor(min/60);
var days = Math.floor(hrs/24);
sec = string(sec % 60);
if (sec.length &lt; 2) {
	sec = "0" + sec;
}
min = string(min % 60);
if (min.length &lt; 2 ) {
	min = "0" + min;
}
hrs = string(hrs % 24);
if (hrs.length &lt; 2 ) {
	hrs = "0" + hrs;
}
days = string(days);

var counter:String = days + ":" + hrs + ":" + min + ":"+ sec;
time_txt.text = counter;

```

}

thanks
