title: JQuery Datepicker - setting MinDate based on current time
body: <p>I'm using JQuery Datepicker for customers to choose a delivery date. I want to be able to check if the customer is ordering before noon and if so next day delivery is available. If they are ordering after noon, next day delivery is unavailable and so that day is unselectable.</p>
  
  <p>I've got some code to check against the current time but how to I add this value into MinDate in the settings at the top?</p>
  
  <p>Thank you!</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>&lt;div class="delivery-date"&gt;
    &lt;p&gt;
      &lt;label for="date"&gt;Select a date for delivery below:&lt;/label&gt;
      &lt;input id="date" type="text" name="properties[delivery-date]" readonly="readonly" style="background:white; width:30%" class="required" data-error="Please choose a delivery date." /&gt;
    &lt;/p&gt;
  &lt;/div&gt;
  
  &lt;script&gt;
  jQuery(function() {
    jQuery("#date").datepicker( { 
      // minDate: new Date(((new Date).getTime() + 49 * 60 * 60 * 1000) ), 
      minDate: checkBeforeNoon,
      maxDate: "+2M", // show up to 2 months
      dateFormat: 'dd/mm/yy',
      beforeShowDay: available_delivery_dates 
    } );
  });
    
  
  /*==========  check time  ==========*/
  
  // if time before 12pm, offer next day delivery
  
  function checkBeforeNoon(nextDayDelivery){
  
    var startTime = '12:00 AM';
    var endTime = '12:00 PM';
  
    var curr_time = getval();
  
  
    if (get24Hr(curr_time) &gt; get24Hr(startTime) &amp;&amp; get24Hr(curr_time) &lt; get24Hr(endTime)) {
        // before 12pm - next day delivery available
        var nextDayDelivery = '+1d';
  
    } else {
       // after 12pm - next day delivery unavailable
       var nextDayDelivery = '+2d';
    }
  
    function get24Hr(time){
        var hours = Number(time.match(/^(\d+)/)[1]);
        var AMPM = time.match(/\s(.*)$/)[1];
        if(AMPM == "PM" &amp;&amp; hours&lt;12) hours = hours+12;
        if(AMPM == "AM" &amp;&amp; hours==12) hours = hours-12;
        
        var minutes = Number(time.match(/:(\d+)/)[1]);
        hours = hours*100+minutes;
        console.log(time +" - "+hours);
        return hours;
    }
  
    function getval() {
        var currentTime = new Date()
        var hours = currentTime.getHours()
        var minutes = currentTime.getMinutes()
  
        if (minutes &lt; 10) minutes = "0" + minutes;
  
        var suffix = "AM";
        if (hours &gt;= 12) {
            suffix = "PM";
            hours = hours - 12;
        }
        if (hours == 0) {
            hours = 12;
        }
        var current_time = hours + ":" + minutes + " " + suffix;
  
        return current_time;
  
    }
  }
  
  /*==========  Make sundays always unavailable  ==========*/
  
  
  function available_delivery_dates(date) {
  
    var sunday = 0; // unavailable for delivery
    var mon = 1
    var tue = 2;
    var wed = 3;
    var thu = 4;
    var fri = 5;
    var sat = 6;
    
    var day_of_week = date.getDay();
    var not_sun = day_of_week &gt; 0;
    
    if(not_sun){
      var day = date.getDate();
      return [true, ''];  
    }
    else{
      // all else - do not allow
      return [false, ' ', 'Delivery is unavailable on this day'];
    }
  
    
    
  }
    
  &lt;/script&gt;</code></pre>
  </div>
  </div>
  </p>