javascript date + 1

后端 未结 7 1372
逝去的感伤
逝去的感伤 2020-12-29 02:34

How do I take today\'s date and add 1 day to it?

If possible, inline please?

7条回答
  •  太阳男子
    2020-12-29 02:54

    Add 30 days and set the date value to datepicker

    Example :

    $(document).ready(function() {
        var myDate = new Date();
    
        //add a day to the date
        myDate.setDate(myDate.getDate() + 30);        
    
        var end_date = new Date(myDate.getFullYear(), myDate.getMonth(), myDate.getDate());
    
        $('#datepicker').datepicker({
            format: 'dd-mm-yyyy',
            orientation: 'bottom'
        });
    
        $('#datepicker').datepicker('setDate', end_date);
    });
    

提交回复
热议问题