我想要完成的事情是我们每周二和周四发货,我想限制如果订单是在周一下午 5 点之后下达,那么他们必须等到周五。如果在星期四下午 5 点之后的订单,他们必须等到星期二。
function freeDelivery($date){
$holidays = array("05/30/2012","07/04/2012","09/05/2012","11/24/2012","11/25/2012","12/25/2012","12/31/2012","01/01/2013","05/28/2013","07/04/2013","09/03/2013","11/22/2013","11/23/2013","12/25/2013");
$checkday = strtotime($date);
// check if it's a holiday
while(in_array(date("m/d/Y",$checkday), $holidays)) {
$checkday = strtotime(date("m/d/Y",$checkday)." +1 day");
}
//sun
if (date("w",$checkday) == 0) {
$checkday = strtotime(date("m/d/Y",$checkday)." +2 day");
}
//mon
elseif (date("w",$checkday) == 1) {
$checkday = strtotime(date("m/d/Y",$checkday)." +1 days");
}
//tue
elseif(date("w",$checkday) == 2) {
$checkday = strtotime(date("m/d/Y",$checkday)." +2 days");
}
//wen
elseif (date("w",$checkday) == 3) {
$checkday = strtotime(date("m/d/Y",$checkday)." +1 days");
}
//thur
elseif (date("w",$checkday) == 4) {
$checkday = strtotime(date("m/d/Y",$checkday)." +5 days");
}
//fri
elseif (date("w",$checkday) == 5) {
$checkday = strtotime(date("m/d/Y",$checkday)." +4 days");
}
//sat
elseif (date("w",$checkday) == 6) {
$checkday = strtotime(date("m/d/Y",$checkday)." +3 days");
}
// make sure it's not another holiday
while(in_array(date("m/d/Y",$checkday), $holidays)) {
$checkday = strtotime(date("m/d/Y",$checkday)." +1 day");
}
return $checkday;
}
上面的代码用于根据一周中的日期确定发货日期。
谢谢您的任何帮助,非常感谢。