Yep, the Beverleyh answer is correct but that code... it's weird.

I have some advice for you:
Have a look these opensources libraries, Moment.js and Date.js!
All you need to better manage the...