简体   繁体   中英

How to get 2 dates excluding weekend using PHP

I tried to add this code, but it doesn't exclude weekends.

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";
} 

You can use the strtotime weekday date time formats

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";
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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