PHP yesterday date

All your question about php
Post Reply
Peter_w
Posts: 28
Joined: Tue Aug 19, 2008 9:28 am

PHP yesterday date

Post 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,
chris
Site Admin
Posts: 205
Joined: Mon Jul 21, 2008 9:52 am

Re: PHP yesterday date

Post 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.
Post Reply