strtotime 减去小时和分钟

strtotime minus hours and minutes

我有这个代码:

<?php 
    $date = date('Y-m-d H:i:s', strtotime('-6 hours', (int)get_the_time('U'))); 
    echo $date; 
?>

如您所见,时间从时间中减去 6 小时,我想减去小时和分钟,所以我尝试了这个:

<?php 
    $date = date('Y-m-d H:i:s', strtotime('-6 hours', '-23 minutes', (int)get_the_time('U'))); 
    echo $date; 
?>

但是不管用,知道吗?

提前致谢

strtotime 函数只需要 2 个参数。

int strtotime ( string $time [, int $now = time() ] )

所以你应该试试下面的格式:

$date = strtotime('-6 hours, -43 minutes', $time);

测试代码:

<?php
$time = time();
$date = strtotime('-6 hours', $time);
echo date('d-m-y H:i', $time);
echo date('d-m-y H:i', $date);


$date = strtotime('-6 hours, -43 minutes', $time);
echo date('d-m-y H:i', $time);
echo date('d-m-y H:i', $date);

输出:

19-10-17 00:44
18-10-17 18:44

19-10-17 00:44
18-10-17 18:01
$time=time();
$datetime_from = date("Y-m-d H:i", strtotime("-43 minutes", strtotime("-6 hours",$time)));