Does anyone know if there is a javascript ONLY way to convert an epoch number into a human readable date? I have this code, but I keep getting back a number. I want to convert this number into a human readable date if possible (ex: 2012/3/23).
This was a resource I used for my code… http://www.epochconverter.com/programming/
Play with my jsfiddle … http://jsfiddle.net/4FSEp/
var myDate=new Date();
myDate = myDate.setFullYear(2012,3,23);
document.write(myDate);
document.write(myDate.toGMTString()+"<br>"+myDate.toLocaleString());
Change
to
(edit — wow I didn’t know
setFullYear()could also take a month and a day-of-month 🙂Those routines modify the date object, so there’s no need to re-assign.
edit — if you have a date, and you want to move it to five days ahead of that date, you’d do this: