title: How to validate the date time in datepicker?
body: <p>I have two datetimepickers in a form  to enter the start time and end time.<br>
  The ID of the start time is "startTime" and that of end time is "endTime".<br></p>
  
  <pre><code>var startTime = document.getElementById("startTime");
  var endTime = document.getElementById("endTime");
  
  if (new Date(startTime.value).getTime() &gt; new Date(endTime.value).getTime()) {
       alert("End Time should be greater than Start Time");
       return false;
  }
  </code></pre>
  
  <p>I tried to compare the start time and end time and validated that the start time should not be greater than the end time. <br>
  Now, I want to write a validation, so that the end time should aleast be greater than the start time by 1 hour.<br>
  sampleLink: <a href="http://trentrichardson.com/examples/timepicker/" rel="nofollow">DateTimePicker Example</a></p>
  
  <pre><code>$('#startTime').datetimepicker({
      onClose: function(dateText, inst) {
          var endDateTextBox = $('#endTime');
          if (endDateTextBox.val() != '') {
              var testStartDate = new Date(dateText);
              var testEndDate = new Date(endDateTextBox.val());
              if (testStartDate &gt; testEndDate)
                  endDateTextBox.val(dateText);
          }
          else {
              endDateTextBox.val(dateText);
          }
      },
      onSelect: function (selectedDateTime){
          var start = $(this).datetimepicker('getDate');
          $('#endTime').datetimepicker('option', 'minDate', new Date(start.getTime()));
      }
  });
  $('#endTime').datetimepicker({
      onClose: function(dateText, inst) {
          var startDateTextBox = $('#startTime');
          if (startDateTextBox.val() != '') {
              var testStartDate = new Date(startDateTextBox.val());
              var testEndDate = new Date(dateText);
              if (testStartDate &gt; testEndDate)
                  startDateTextBox.val(dateText);
          }
          else {
              startDateTextBox.val(dateText);
          }
      },
      onSelect: function (selectedDateTime){
          var end = $(this).datetimepicker('getDate');
          $('#startTime').datetimepicker('option', 'maxDate', new Date(end.getTime()) );
      }
  });
  </code></pre>
  
  <p>I tried with this and got the start time and end time to be the same. But I'm not sure how to increase the end time by 1 hour.<br></p>
  
  <p>For example, if the starttime value is 03-23-2012 10:00 AM i want the endtime as 03-23-2012 11:00 AM
  Can any one help me on this please?</p>
  
  <p>Thanks</p>