js 日期格式化
//日期格式化"2017-07-05" function formatTime(date) { var year = date.getFullYear(); var month = date.getMonth() + 1, month = month < 10 ? '0' + month : month; var day = date.getDate(), day = day < 10 ? '0' + day : day; return year + '-' + month + '-' + day; } //使用方法, var date = new Date(); var data1 = formatTime(date); //"2019-04-03" date.setDate(date.getDate() + 1);//加一天 var data2 = formatTime(date); //"2019-04-04"