本文介绍了PHP日期(不包括周末)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我目前正在建立一个仅在周一至周五提供送货服务的网站.
I am currently doing a website which offers delivery Monday through Friday only.
我正在尝试弄清楚如何添加交货日期.例如:
I am trying to figure out how to add delivery date. For e.g:
今天订购,您可以期望以DD/MM/YY交货"
"Order today and you can expect delivery on DD/MM/YY"
上述日期要求排除任何周末
The above date would require to exclude any weekends
因此,基本上,如果今天订购,则交货日为4个工作日,不包括周末.
So basically if ordered today the delivery day is 4 working days later excluding weekends.
推荐答案
尝试以下逻辑.您可以根据需要进行修改.
Try this logic. You can modify it according to your needs.
$curdate = '2014-07-19';
$mydate=getdate(strtotime($curdate));
switch($mydate['wday']){
case 0: // sun
case 1: // mon
$days = 4;
break;
case 2:
case 3:
case 4:
case 5:
$days = 6;
break;
case 6: // sat
$days = 5;
break;
}
echo date('Y-m-d', strtotime("$curdate +$days days"));
这篇关于PHP日期(不包括周末)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!