如何使用 PHP 获取 2 个日期,不包括周末



我试图添加此代码,但它不排除周末。

add_action("woocommerce_after_add_to_cart_button", "custom_shipping_estimate");
function custom_shipping_estimate(){
$date1 = date("F j",strtotime("+ 2 days"));
$date2 = date("F j",strtotime("+ 4 days"));
echo "Arrives between $date1 and $date2";
} 

您可以使用strtotimeweekday日期时间格式

add_action("woocommerce_after_add_to_cart_button", "custom_shipping_estimate");
function custom_shipping_estimate(){
$date1 = date("F j",strtotime("+ 2 weekday"));
$date2 = date("F j",strtotime("+ 4 weekday"));
echo "Arrives between $date1 and $date2";
}

最新更新