Date time picker maxDate issue

by harifrais

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.2/moment.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.7.14/js/bootstrap-datetimepicker.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.7.14/css/bootstrap-datetimepicker.min.css">
<div class="row">
    <div class="col-md-12">
        Not Working <input type="text" class="datetime-notworking" />
        Working <input type="text" class="datetime-working" />
    </div>
</div>

JavaScript

today = new moment();
    $('.datetime-working').datetimepicker({
        format: "YYYY-MM-DD HH-mm-ss",
        stepping: 1,                  //set the minute stepping
        maxDate: moment().endOf('day'),   // works also if used moment.add(1, 's')
        useCurrent: true,                   //when true, picker will set the value to the current date/time
        showTodayButton: true,                    //shows the today indicator
        sideBySide: true                   //show the date and time picker side by side
    
    });


    $('.datetime-notworking').datetimepicker({
        format: "YYYY-MM-DD HH-mm-ss",
        stepping: 1,                  //set the minute stepping
        maxDate: moment(),
        useCurrent: true,                   //when true, picker will set the value to the current date/time
        showTodayButton: true,                    //shows the today indicator
        sideBySide: true                   //show the date and time picker side by side
    
    });
    
    
var d1 = "2020-08-21T13:15:24.802Z1";
var d2 = "2020-08-21T16:35:07.000Z";


var max = Math.max(d1, d2);

// Will give you the max Date
console.log(JSON.stringify(new Date(max)));