繁体   English   中英

一段时间后在jquery datepicker中禁用日期

[英]disable date in jquery datepicker after some time

我为一个客户创建了一个日期选择器。 他们从事鲜花递送业务,他们提供当天中午12点之前下单的当天递送服务。 所以我为此创建了以下代码。 其功能的基本概述是:

->如果时间大于12:00(中午),请禁用当前日期,以使客户无法下订单进行当天交货。

但是最近,某个订单可以在下午6点进行当天交付。 这是一个问题。

这是我到目前为止所做的:

<?php
// This is how i check for current date and time and if the delivery cut off time is passed add that date to disabled dates array. so customer can not put order of the current date.
 current_day = date( "w" );
 $todays_cut_off_time = get_option("weekday_cut_off_time_$current_day");
  $todays_cut_off_time = strtotime($todays_cut_off_time);
  $current_time = date( 'H:i', current_time( 'timestamp', 0 ) );
  $current_time = strtotime($current_time);
  if($todays_cut_off_time < $current_time)
  {
    $disabled_dates_array[] = date("m/d/Y");
  } 
?>
<script>
jQuery( document ).ready(function() {

 var disableddates = <?php echo $disabled_delivery_dates; ?>;  //contains list of disabled dates by admin.

 exceptions    = <?php echo $holiday_exception_dates; ?>; //contains dates those are exceptional

  function DisableSpecificDates(date) {

   var m = date.getMonth() + 1;
   if(m <= 9)
     m = '0'+m;
     var d = date.getDate();
   if(d <= 9)
    d = '0'+d;
    var y = date.getFullYear();


  // First convert the date in to the mm-dd-yyyy format
  // Take note that we will increment the month count by 1
  var currentdate = m + '/' + d + '/' + y ;

  // We will now check if the date belongs to exceptions array
  for (var i = 0; i < exceptions.length; i++) {

 // Now check if the current date is in disabled dates array.
 if (jQuery.inArray(currentdate, exceptions) != -1 ) {

 return [true];

 }

 }

 // We will now check if the date belongs to disableddates array
 for (var i = 0; i < disableddates.length; i++) {

 // Now check if the current date is in disabled dates array.
 if (jQuery.inArray(currentdate, disableddates) != -1 ) {

 return [false];

  }

 }

 // In case the date is not present in disabled array, we will now check if it is a weekend.
// We will use the noWeekends function
//var weekenddate = jQuery.datepicker.noWeekends(date);
  var day = date.getDay();
  return [(<?php echo $disabled_week_day; ?>), ''];

}
function FindMinDate(date){
  return 0;
 }
jQuery( "#delivery_date" ).datepicker({
   dateFormat: 'mm-dd-yy',
   minDate: 0,
   beforeShowDay: DisableSpecificDates
});
});
 </script>

有人可以指导我朝正确的方向完成此工作。 提前致谢。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM