是否可以根据其他日期时间选择器中的选定日期禁用日期时间选择器的先前日期

Is it possible to disable previous dates of a datetimepicker according to selected date in other datetimepicker

我正在为开始日期使用两个日期时间选择器,并且 enddate.I 想在我 select 日期在 startdate.For 示例中禁用结束日期中的所有前一个日期 if i select 29 /04/2020 in startdate than in enddate 必须禁用 29/04/2020 之前的所有日期。 下面是代码:

$(function(){
    $('#startDate').datetimepicker({
        format: 'dd-mm-yyyy  hh:ii',
        endDate: '+0d',
        autoclose: true,

    });
    $('#endDate').datetimepicker({
        format: 'dd-mm-yyyy hh:ii',
        endDate: '+0d',
        autoclose: true
    });
});

如何修改代码以获得预期的结果。

请尝试以下代码,它正在运行。

<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Testing Date Time Picker</title>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"> </script>
  <link href="https://cdnjs.cloudflare.com/ajax/libs/jquery-datetimepicker/2.5.20/jquery.datetimepicker.css" rel="stylesheet" />
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-datetimepicker/2.5.20/jquery.datetimepicker.full.js"></script>
</head>
<body>
 <label>Start Date: </label>
 <input id="startDate" type="text" />
 <label>End Date: </label>
 <input id="endDate" type="text" />
 <script>
  $(document).ready(function(){
   $('#startDate').datetimepicker({
    format: 'd-m-Y H:i',
    closeOnDateSelect:true,
    onChangeDateTime:function(dp,$input){
     //need to convert date to format yyyy/m/d
     var val = $input.val();
     $('#endDate').datetimepicker({minDate: val, formatDate:'d-m-Y H:i'});
    }
   });
   $('#endDate').datetimepicker({
    format: 'd-m-Y H:i',
    closeOnDateSelect:true,
   });
  });
 </script>
</body>
</html>