Php get timestamp of previous day midnight-ThrowExceptions

Exception or error:

Am trying to get the timestamp of previous day midnight

That is if today is thursday , get the timestamp of wednesday midnight.

How do i go about this

i have tried

$lastdaymidnight = strtotime() //am stuck

What do i need to add to strtotime?

How to solve:

try this

$date = new DateTime();
$date->setTimestamp(strtotime('yesterday midnight'));

Answer´╝Ü

One liner:

$date = new DateTime('yesterday midnight');

Leave a Reply

Your email address will not be published. Required fields are marked *