Geoff
Geoff

Reputation: 6649

Php get timestamp of previous day midnight

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?

Upvotes: 0

Views: 2737

Answers (2)

David DeMar
David DeMar

Reputation: 2670

One liner:

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

Upvotes: 0

Bai Nguyen
Bai Nguyen

Reputation: 834

try this

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

Upvotes: 7

Related Questions