我正在制作一个我的结束时间设定的程序。说今天结束时间设置为“2015-08-23 22:15:00”。
现在,如果客户购买了60分钟的服务,那么我希望在"2015-08-23 22:15:00"
( - 60分钟)之前发送消息到达地点"2015-08-23 21:15:00"
。那么我怎样才能以上述方式减去时间。
我得到了this link.
的解决方案工作正常
echo date('Y-m-d H:i:s', strtotime('-60 minutes'));
但不适用于
echo date('2015-08-23 22:15:00', strtotime('-60 minutes'));
答案 0 :(得分:1)
您正在以错误的方式使用日期。这就是你想要的:
[[1]]
[1] 1
[[2]]
[1] 4
[[3]]
[1] 9
[[4]]
[1] 16
[[5]]
[1] 25
[[6]]
[1] 36
[[7]]
[1] 49
[[8]]
[1] 64
[[9]]
[1] 81
[[10]]
[1] 100
答案 1 :(得分:-1)
我建议使用DateTime类并修改设置时间:http://php.net/manual/de/datetime.modify.php
$date = new DateTime('2015-08-23 22:15:00');
$date->modify('-60 minutes'); // Or $date->modify('-1 hour');