• Resolved Jack

    (@moxie)


    Not really a WP question, but I’m doing a query to seperate past from future posts, to make a list of upcoming events. In this case events on this day should still be on the list with upcoming events (because they’re not past yet…).

    I have this:

    $now= date("Y-m-d H:i:s",$t);
    if(($post->post_date)>$now)

    but this will move events which happen now (= this day) to the list of past events. How can I modify it to include the present day?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator Samuel Wood (Otto)

    (@otto42)

    www.remarpro.com Admin

    That’s not a good way to compare dates. Convert to unix timestamps instead.

    $now = time();
    $oneDayAgo = $now - (24*60*60); //24 hours * 60 min * 60 sec
    $posttime = the_time('U');
    if($posttime > $oneDayAgo) {
    // post is older than 1 day
    }
    Thread Starter Jack

    (@moxie)

    Didn’t know that. Thanks for the information! ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘PHP: date minus one day’ is closed to new replies.