/ Published in: Other
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function adate(daysFromNow) { var date, datestr, mm, dd; datestr = new Date().getTime(); if (!!daysFromNow) { datestr += (1000 * 60 * 60 * 24 * daysFromNow); } date = new Date(datestr); mm = date.getMonth() + ''; if (mm.length == 1) { mm = '0' + mm; } dd = date.getDate() + ''; if (dd.length == 1) { dd = '0' + dd; } return date.getFullYear() + '-' + mm + '-' + dd; }