-1

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

user3318546
  • 75
  • 1
  • 7

3 Answers3

3

Just try with:

$yesterday = date('Y-m-d', strtotime('yesterday'));
hsz
  • 148,279
  • 62
  • 259
  • 315
  • 1
    Why was my answer downvoted ? – hsz Mar 03 '14 at 10:04
  • Im still wondering why its getting up- and downvoted all the time. Kinda funny to watch. – Realitätsverlust Mar 03 '14 at 10:05
  • 3
    Probably because while the answer is correct, it answers an obviously duplicate, obviously help-vampiric, obviously something-you-shouldn't-answer question. The community expects a 34k user to vote to close the question, instead of answering it. – Madara's Ghost Mar 03 '14 at 10:27
0

You could use something like:

date("F j, Y", time() - 60 * 60 * 24);
Qantas 94 Heavy
  • 15,750
  • 31
  • 68
  • 83
Steve
  • 1,371
  • 1
  • 16
  • 38
0

You can also use DateTime:

$date = new DateTime('');
$date->modify('-1 day');
echo $date->format('Y-m-d') . "\n";
Qantas 94 Heavy
  • 15,750
  • 31
  • 68
  • 83
Nambi
  • 11,944
  • 3
  • 37
  • 49