<script type="text/javascript"> function init(){ var tempDate = new Date(); var currDate = ChangeDateToString(tempDate); var startDate = document.getElementById("queryStartDate"); var endDate =document.getElementById("queryEndDate"); startDate.value = currDate; endDate.value = currDate; } function ChangeDateToString(DateIn){ var Year = 0; var Month = 0; var Day = 0; var CurrentDate = ""; //初始化时间 Year = DateIn.getYear(); Month = DateIn.getMonth()+1; Day = DateIn.getDate(); CurrentDate = Year + "-"; if (Month >= 10 ){ CurrentDate = CurrentDate + Month + "-"; } else{ CurrentDate = CurrentDate + "0" + Month + "-"; } if (Day >= 10 ){ CurrentDate = CurrentDate + Day ; } else{ CurrentDate = CurrentDate + "0" + Day ; } return CurrentDate; } </script>