Calculate business days

后端 未结 30 2121
猫巷女王i
猫巷女王i 2020-11-22 05:16

I need a method for adding \"business days\" in PHP. For example, Friday 12/5 + 3 business days = Wednesday 12/10.

At a minimum I need the code to understand weekend

30条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-22 06:08

    Today is (ORDER DATE): " . '' . date('l, F j, Y', $today) . "

    "; //The numerical representation for day of week (Ex. 01 for Monday .... 07 for Sunday $today_numerical = date("N",$today); //leadtime_days holds the numeric value for the number of business days $leadtime_days = $_POST["leadtime"]; //leadtime is the adjusted date for shipdate $shipdate = time(); while ($leadtime_days > 0) { if ($today_numerical != 5 && $today_numerical != 6) { $shipdate = $shipdate + (60*60*24); $today_numerical = date("N",$shipdate); $leadtime_days --; } else $shipdate = $shipdate + (60*60*24); $today_numerical = date("N",$shipdate); } echo 'Estimated Ship date: ' . '' . date('l, F j, Y', $shipdate) . ""; ?>

提交回复
热议问题