我想把时间减去30分钟


I want to subtract 30 minutes from a time

你好我的问题很简单,请让我知道我如何从时间减去30分钟我的代码是:

$endDate = date("Y-m-d H:i:s", $futureDate);

        $d_newdate = strtotime($endDate);
        $d_newdate1 = $d_newdate - ('30 minutes');
        echo $d_newdate2 = date("Y-m-d H:i:s", $d_newdate1);die("workings");

这个代码增加了一个小时的时间,这是错误的。我想减去30分钟

$date = '2015-08-02 15:30:00';
echo $date."<br>";
echo date('Y-m-d H:i:s',strtotime("-30 minutes",strtotime($date)));
echo date("Y-m-d H:i:s")."<br>";
echo date("Y-m-d H:i:s",strtotime('-30 minutes'));

尝试使用

$d_newdate = strtotime($endDate);
$d_newdate1 = $d_newdate - (30 * 60);
$new_time = date("Y-m-d H:i:s", $d_newdate1);