2 回答

TA貢獻(xiàn)1828條經(jīng)驗(yàn) 獲得超3個贊
在 PHP 中輕松使用strtotime("+45 minutes")
$deliveryIn30 = date("Y-m-d H:i:s",strtotime(date("Y-m-d H:i:s")." +30 minutes"));
$deliveryIn45 = date("Y-m-d H:i:s",strtotime(date("Y-m-d H:i:s")." +45 minutes"));
echo "Your order will arrive between {$deliveryIn30} and {$deliveryIn45}.";
編輯:如果你想使用WordPress安裝當(dāng)?shù)貢r間
$time = current_time( 'mysql' );
$deliveryIn30 = date( 'Y-m-d H:i:s', strtotime($time) + 1800); // 30 mins * 60 secs = 1800
$deliveryIn45 = date( 'Y-m-d H:i:s', strtotime($time) + 2700); // 45 mins * 60 secs = 2700
echo "Your order will arrive between {$deliveryIn30} and {$deliveryIn45}.";

TA貢獻(xiàn)1831條經(jīng)驗(yàn) 獲得超10個贊
您需要用交貨日期時間減去當(dāng)前日期時間,如下所示
$datetime_now = new DateTime();
$delivery_dt = new DateTime('2020-08-08 20:20:00');
$count_down= $datetime_now->diff($delivery_dt);
echo $count_down->format('%h hours %i minutes');
- 2 回答
- 0 關(guān)注
- 116 瀏覽
添加回答
舉報