如何检查date()函数是否减一?

Is it possible to check if the date ("j-1 F-1")???

I'm a noob so some script would help! Postdate is in a format like: 14 October.

if ($postdate == date("j F")) {$postdate = "today";} THIS WORKS...

But I need to check the $postdate for the "yesterday" value as well!

Q: How to check for yesterday? that is, date()-1 somehow.

Thanks again

date('j F', strtotime('-1 day'));

Will retrieve the "yesterday" timestamp. So :

if ($postdate == date('j F', strtotime('-1 day'))) {$postdate = "yesterday";}

use strtotime or mktime and then check if your date is between that value and todays timestamp.

if($date > strtotime('yesterday') && $date < time()) { echo 'yesterday or today' }

if($date > mktime(0,0,0,date('n'),date('j')-1) && $date < time()) { echo 'yesterday or today' }
$yesterday = date('j F', mktime(0,0,0, date('m'), date('d')-1, date('Y')));

The "magic" is in the mktime call. I seriously advise you to read the relevant parts of the PHP manual: this is almost a verbatim duplication of Example #3!