1 <script type="text/javascript"> 2 function addDay(datetime, days) { 3 var old_time = new Date(datetime.replace(/-/g, "/")); //替换字符,js不认2013-01-31,只认2013/01/31 4 var fd = new Date(old_time.valueOf() + days * 24 * 60 * 60 * 1000); //日期加上指定的天数 5 var new_time = fd.getFullYear() + "-"; 6 var month = fd.getMonth() + 1; 7 if (month >= 10) { 8 new_time += month + "-"; 9 } else { 10 //在小于10的月份上补0 11 new_time += "0" + month + "-"; 12 } 13 if (fd.getDate() >= 10) { 14 new_time += fd.getDate(); 15 } else { 16 //在小于10的日期上补0 17 new_time += "0" + fd.getDate(); 18 } 19 return new_time; //输出格式:2013-01-02 20 } 21 22 alert(addDay("2013-11-12", 1)); //弹出值:2013-11-13 23 </script>