2 回答
TA贡献1828条经验 获得超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安装当地时间
$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贡献1831条经验 获得超10个赞
您需要用交货日期时间减去当前日期时间,如下所示
$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 关注
- 74 浏览
添加回答
举报