1 person found this helpful
What you probably need to do is use the Date.getTime() method for both dates, then subtract the older value from the current value which will give you the number of milliseconds between the two dates.
Maybe I'm missing something....
myTime= new Date(1245972529 * 1000).getTime(); nowTime = new Date().getTime(); oMillisElapsed = new Date(nowTime - myTime); day = numToStr(oMillisElapsed.getDate()); min = numToStr(oMillisElapsed.getMinutes()); sec = numToStr(oMillisElapsed.getSeconds()); hour = numToStr(oMillisElapsed.getHours());
oMillisElapsed: Wed Dec 31 16:54:29 GMT-0800 1969
I wanted something like
You are assigning a new Date to the value, so when you try to use the Date function to acquire its data, you are getting what those functions produce, which isn't what I believe you want. I believe you want to get the amount of time (days, hours, minutes, etc) between then and now. Did you try doing what I suggested? What you would end up doing is taking the resulting miiliseconds from that and doing the conversion to days, hours, seconds, etc...
THAT HELPED A LOT!!!
I found this script which too care of the job
var date:Date = *the date you are tracking to from now*; var today:Date = *the current time or the start time you are recording from to the date instance*; var dif:int = date.getTime() - today.getTime(); dif /= 1000; //translate to seconds var days:int = Math.floor( dif / ( 60 * 60 * 24 ) ); dif -= days * 60 * 60 * 24; var hours:int = Math.floor( dif / (60 * 60) ); dif -= hours * 60 * 60; var mins = Math.floor( dif / 60 ); dif -= mins * 60; var secs:int = dif;