Page 1 of 1

PHP yesterday date

Posted: Mon Jul 19, 2010 9:07 pm
by Peter_w
Hello,

I want to get yesterdays date.
Is there an easy way to do it?
Because the mktime-function doesn't seam to be the best option.

Thanks,

Re: PHP yesterday date

Posted: Mon Jul 19, 2010 9:24 pm
by chris
Hi,

mktime() works fine for me:

Code: Select all

$yesterday=date('Y-m-d', mktime(0, 0, 0, date("m") , date("d") - 1, date("Y")));
But you can also use the following code:

Code: Select all

$yesterday=date("Y-m-d", time()-86400);
The result should be the same.