1.参数
num:该参数为数字,为正数就是当前日期天数往后移的天数,比如正数1就是明天,-1就是昨天
str:日期中间的间隔符,输入'-'就为'YYYY-MM-DD',或输入'/'就为'YYYY/MM/DD'
function getDay(num, str) { var today = new Date(); var nowTime = today.getTime(); var ms = 24*3600*1000*num; today.setTime(parseInt(nowTime + ms)); var oYear = today.getFullYear(); var oMoth = (today.getMonth() + 1).toString(); if (oMoth.length <= 1) oMoth = '0' + oMoth; var oDay = today.getDate().toString(); if (oDay.length <= 1) oDay = '0' + oDay; return oYear + str + oMoth + str + oDay; }