Pre-Populated Date in Text Field
- by user2537332
I am trying to pre-populate a text box with today's date, but for some reason, it keeps showing today's date as 5/30/13, which is a month behind. This code should just be pulling the local time so why is it a month behind? Here is my code, can someone please tell me why the current date is off...Please help, :)
var dateToday=new Date();
function loadDate(){
var today=dateToday.getMonth() + "/"
+dateToday.getDate()+"/"+dateToday.getFullYear();
document.forms[0].curDate.value=today;
}
function orderReady(orderTime){
dateToday.setDate(dateToday.getDate()+orderTime);
var ready=dateToday.getMonth()+"/"
+dateToday.getDate()+"/"+dateToday.getFullYear();
document.forms[0].puDate.value=ready;
}
<body onload="loadDate();">
<p>Today's Date<br />
<input type="text" name="curDate" size="50" /><br />