其他分享
首页 > 其他分享> > 日期在一个列表中往后加上一天

日期在一个列表中往后加上一天

作者:互联网

//添加日期函数
	   function getFormatDate(arg) {
            if (arg == undefined || arg == '') {
                return '';
            }
            var re = arg + '';
            if (re.length < 2) {
                re = '0' + re;
            }

            return re;
        }
        function addDate(date, days) {
          
            if (typeof (data) == 'string') {
                date = (date + '').replace(/-/g, "/");
            }
           
            var date = new Date(date);
            date.setDate(date.getDate() + days);
            var month = date.getMonth() + 1;
            var day = date.getDate();
            return date.getFullYear() + '-' + getFormatDate(month) + '-' + getFormatDate(day);
        }
	function addOneDay(date, dateDure) {
                        while ($.inArray($.trim(date),dateDure ) >= 0) {
                            date = addDate(new Date(date.replace(/-/g, "/")), 1)
                        }
                        return date;
                    }
                    var start = '2019-05-15';
                    var rang = ['2019-05-15','2019-05-17','2019-05-18','2019-05-19'];
                    var res = addOneDay(start,rang);
                    console.log(res);

标签:re,05,往后,列表,var,日期,2019,arg,date
来源: https://blog.csdn.net/u012258564/article/details/90297721