How to subtract 00:00:00
example with 1 hour?
I've tried:
$minus1=strtotime(00:00:00)-strtotime('-1 hour');
but instead of an answer of 23:00:00
, I got -1502671524
instead.
How to subtract 00:00:00
example with 1 hour?
I've tried:
$minus1=strtotime(00:00:00)-strtotime('-1 hour');
but instead of an answer of 23:00:00
, I got -1502671524
instead.
收起
You can use DateTime and DateInterval option to do in PHP.
$date = new DateTime('00:00:00'); $date->sub(new DateInterval('PT1H00M')); echo $date->format('H:i:s') . " ";
The P stands for Period. The T stands for Timespan. H stands for Hour to reduce and finally M stands for Minutes to reduce.
See DateTime, DateTime::sub, and DateInterval in the PHP manual. You'll have to set the DateTime
to the appropriate date and time, of course.
报告相同问题?