I've tried my level best but couldn't get the result. What I need is the date in YYYY-MM-DD format. Here is my current code:
function AddDays(days) { var thisDate = new Date(); thisDate.setDate(thisDate.getDate() + days); var dd = ( thisDate.getFullYear() + '-' + (thisDate.getMonth() + 1) + '-' + thisDate.getDate() ); return dd; } alert(AddDays(365));
I'm getting "2014-8-7" as result but I want to get it as YYYY-MM-DD. I need it to look like "2014-08-07".