how do I subtract 24 hour from date time object in PHP

$date = (new \DateTime())->modify('-24 hours');

or

$date = (new \DateTime())->modify('-1 day');

(The latter takes into account this comment as it is a valid point.)

Should work fine for you here. See http://PHP.net/datetime

$date will be an instance of DateTime, a real DateTime object.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)