Frage

I have

$today = date("Y-m-d");

and I like to define also $yesterday

I tried to do

$yesterday=($today-1)

But it doesn't work

War es hilfreich?

Lösung

Just try with:

$yesterday = date('Y-m-d', strtotime('yesterday'));

Andere Tipps

You could use something like:

date("F j, Y", time() - 60 * 60 * 24);

You can also use DateTime:

$date = new DateTime('');
$date->modify('-1 day');
echo $date->format('Y-m-d') . "\n";
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top