Hello All,

I'm trying to create a countdown script for my mother. She retires in a few years and is literally counting down the days. So I thought it would be nice to have a script so she can SEE exactly how much longer she has. I'm pretty new to JavaScript, but have managed to write several successful scripts, but this one is eluding me. Anyway, here is what I have so far, but can't seem to get it right. I can't even get past the months.

Her retirement date isAugust 31, 2017 at 5:00pm. I would like for it to displayYY:MMD:HH:MM:SS.

If anyone can help, I would appreciate it. Thank you!!

Code:function countretire(){ var today = new Date(); var ayears = today.getFullYear(); var amonths = today.getMonth(); var xmonths = today.getMonth(); var adays = today.getDate(); var xdays = today.getDate(); var ahours = today.getHours(); var xhours = today.getHours(); var aminutes = today.getMinutes(); var xminutes = today.getMinutes(); var aseconds = today.getSeconds(); var xseconds = today.getSeconds(); if(aseconds) aseconds = 59 - aseconds; if(xseconds == 0) aseconds = aseconds + 59; if(aseconds <= 9) aseconds = "0" + aseconds; if(aminutes) aminutes = 59 - aminutes; if(xminutes == 0) aminutes = aminutes + 59; if(aminutes <= 9) aminutes = "0" + aminutes; if(ahours) ahours = ahours + 7; if(ahours) ahours = 23 - ahours; if(xhours >= 17) ahours = ahours - 1; if(ahours <= 9) ahours = "0" + ahours; if(xmonths == 0) adays = 31 - adays; if(xmonths == 0 && xhours >= 17) adays = adays - 1; if(xmonths == 0 && adays <= 9) adays = "0" + adays; if(xmonths == 1) adays = 28 - adays; if(xmonths == 1 && xhours >= 17) adays = adays - 1; if(xmonths == 1 && adays <= 9) adays = "0" + adays; if(xmonths == 2) adays = 31 - adays; if(xmonths == 2 && xhours >= 17) adays = adays - 1; if(xmonths == 2 && adays <= 9) adays = "0" + adays; if(xmonths == 3) adays = 30 - adays; if(xmonths == 3 && xhours >= 17) adays = adays - 1; if(xmonths == 3 && adays <= 9) adays = "0" + adays; if(xmonths == 4) adays = 31 - adays; if(xmonths == 4 && xhours >= 17) adays = adays - 1; if(xmonths == 4 && adays <= 9) adays = "0" + adays; if(xmonths == 5) adays = 30 - adays; if(xmonths == 5 && xhours >= 17) adays = adays - 1; if(xmonths == 5 && adays <= 9) adays = "0" + adays; if(xmonths == 6) adays = 31 - adays; if(xmonths == 6 && xhours >= 17) adays = adays - 1; if(xmonths == 6 && adays <= 9) adays = "0" + adays; if(xmonths == 7) adays = 31 - adays; if(xmonths == 7 && xhours >= 17) adays = adays - 1; if(xmonths == 7 && adays <= 9) adays = "0" + adays; if(xmonths == 8) adays = 30 - adays; if(xmonths == 8 && xhours >= 17) adays = adays - 1; if(xmonths == 8 && adays <= 9) adays = "0" + adays; if(xmonths == 9) adays = 31 - adays; if(xmonths == 9 && xhours >= 17) adays = adays - 1; if(xmonths == 9 && adays <= 9) adays = "0" + adays; if(xmonths == 10) adays = 30 - adays; if(xmonths == 10 && xhours >= 17) adays = adays - 1; if(xmonths == 10 && adays <= 9) adays = "0" + adays; if(xmonths == 11) adays = 31 - adays; if(xmonths == 11 && xhours >= 17) adays = adays - 1; if(xmonths == 11 && adays <= 9) adays = "0" + adays; if(amonths) amonths = amonths + 4; if(amonths) amonths = 11 - amonths; if(xmonths >= 7 && xdays >= 31 && xhours >= 17) amonths = amonths - 1; if(amonths <= 9) amonths = "0" + amonths; if(today){ dispElapsed = "<font face='Arial' size='6'><b><span class='datetime'>" + amonths + ":" + adays + ":" + ahours + ":" + aminutes + ":" + aseconds + "</span></b></font>"; } var e = document.getElementById("countretire"); if(!e) return; if("innerHTML" in e) e.innerHTML = dispElapsed; setTimeout("countretire()", 1000); }