簡體   English   中英

如何使用 PHP 獲得 2 個不包括周末的日期

[英]How to get 2 dates excluding weekend using PHP

我嘗試添加此代碼,但不排除周末。

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

您可以使用 strtotime weekday日期時間格式

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM