PHP DateTime->sub() wont bubble up to days -
if datetime $servertime
e.g. 2016-02-03 00:30:00
, subtract 90 minutes this
$servertime->sub(new dateinterval("pt1h30m"));
the $servertime
2016-02-03 23:00:00
. notice date remains february 3rd. while it's exepcted goes down 1 - should 2016-02-02 23:00:00
. there way achieve this?
you doing wrong or modifying along way:
$servertime = datetime::createfromformat('y-m-d h:i:s', '2016-02-03 00:30:00'); print_r($servertime); $servertime->sub(new dateinterval("pt1h30m")); print_r($servertime);
works fine me: demo.
Comments
Post a Comment