# Current Date Problem

**URL:** <https://forum.kirupa.com/t/current-date-problem/311128>\
**Category:** flash\
**Created:** [June 28, 2010, 5:25pm UTC](https://forum.kirupa.com/t/current-date-problem/311128 "2010-06-28T17:25:41Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Phandral](https://avatars.discourse-cdn.com/v4/letter/p/13edae/32.png) [@Phandral](https://forum.kirupa.com/u/Phandral)\
**Post date:** [June 28, 2010, 5:25pm UTC](https://forum.kirupa.com/t/current-date-problem/311128/1 "2010-06-28T17:25:41Z")

</div>

Hi folks!

I consider myself somewhere between a beginner and intermediate where I can read and understand what’s going on in someone else’s code reasonably well, but I’m still rather clueless if asked to write my own completely from scratch.

That said, I can’t figure out why the following code, (which I have qualms admitting I found on the interwebz) for a timer I’m using for a widget displays the current date as 66 days from the end date which is just only over 30.

* * *

var endDate:Date = new Date(2010,8,3);  
var countdownTimer:Timer = new Timer(1000);  
countdownTimer.addEventListener(TimerEvent.TIMER, updateTime);  
countdownTimer.start();  
function updateTime(e:TimerEvent):void{

var now:Date = new Date();  
var timeLeft:Number = endDate.getTime() - now.getTime();  
var seconds:Number = Math.floor(timeLeft / 1000);  
var minutes:Number = Math.floor(seconds / 60);  
var hours:Number = Math.floor(minutes / 60);  
var days:Number = Math.floor(hours / 24);

seconds %= 60;  
minutes %= 60;  
hours %= 24;

var sec:String = seconds.toString();  
var min:String = minutes.toString();  
var hrs:String = hours.toString();  
var d:String = days.toString();

if (sec.length \< 2) {  
sec = “0” + sec;  
}

if (min.length \< 2) {  
min = “0” + min;  
}

if (hrs.length \< 2) {  
hrs = “0” + hrs;  
}

## var time:String = d + “d.” + hrs + “h.” + min + “m.” + sec + “s”; time\_txt.text = time; }

Can someone tell me where I’ve managed to go wrong?

Thanks in advance!
