javascript - display 270 days prior to the current date in text box -


i trying load date 270 prior today. tried following code looks wrong.

var d = new date(); alert(d.setdate(d.getdate() - 2).tostring()); //2 tried number 

i want display in following format dd/mm/yyyy. thanks

dateobj.getdate return date

dateobj.getmonth return month(0-11)

dateobj.getfullyear return year(yyyy 4 digits)

function pad(n) {    return (n < 10) ? ("0" + n) : n;  }  var d = new date();  d.setdate(d.getdate() - 270);  alert(d);  alert(pad(d.getdate()) + '/' + pad(d.getmonth() + 1) + '/' + d.getfullyear());


Comments