# Countdown timer

**URL:** <https://forum.kirupa.com/t/countdown-timer/227761>\
**Category:** Uncategorized\
**Created:** [June 1, 2007, 8:59pm UTC](https://forum.kirupa.com/t/countdown-timer/227761 "2007-06-01T20:59:02Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![redViper](https://avatars.discourse-cdn.com/v4/letter/r/3d9bf3/32.png) [@redViper](https://forum.kirupa.com/u/redViper)\
**Post date:** [June 1, 2007, 8:59pm UTC](https://forum.kirupa.com/t/countdown-timer/227761/1 "2007-06-01T20:59:02Z")

</div>

hiya folks  
I’m such a noob when it comes to AS but I copied this code from a tutorial site - it’s counting down the time to a certain day. I just wanted to know how do I fix it to countdown to a specific time too? Right now it’s just counting down to the beginning of July 5th 2007.

Thank you 🙂

```auto
this.onEnterFrame = function () {
	
	var today:Date = new Date ();
	var currentYear = today.getFullYear();
	var currentTime = today.getTime();
	
	var targetDate:Date = new Date (currentYear,06,05);
	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 < 2) {
		sec = "0" + sec;
	}
	
	min = string(min % 60);
	if (min.length < 2) {
	min = "0" + min;
	}
	
	hrs = string(hrs % 24);
	if (hrs.length < 2) {
	hrs = "0" + hrs;
	}
	
	days = string(days);
	
	var counter:String = days + "." + hrs + "." + min + "." + sec;
	time_txt.text = counter;
	
	
}

```
