• Resolved nosferke

    (@nosferke)


    Hi, I want to compare the current date with the date of the post itself. My goal is to display all the posts from which the posting date is greater than the date of today (for an event calendar).

    <?php
    $datetoday = date("d-m-Y");
    $datepost = the_time("d-m-Y");
    if ($datetoday < $datepost)
    ?>
    
    ***show the post***

    I know this code is wrong, but I hope someone with more knowledge of PHP can rewrite it into decent PHP.

    Thanks a lot!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter nosferke

    (@nosferke)

    Ok, im one step closer in finding the solution.

    I believe the code should be:

    <?php
    $datetoday = date("d-m-Y");
    $datepost = get_post_modified_time("d-m-Y");
    if ($datetoday <= $datepost)
    ?>
    
    *** here comes the html code that will be used for each post ***
    
    <?php endif; ?>

    But now i get an error for the line which contains <?php endif; ?>
    What should it be instead?

    Thread Starter nosferke

    (@nosferke)

    I found the solution myself. It should have been:

    <?php
    $datetoday = date("d-m-Y");
    $datepost = get_post_modified_time("d-m-Y");
    if ($datetoday <= $datepost): ?>
    
    *** here comes the html code that will be used for each post ***
    
    <?php endif; ?>

    Thanks for the help! ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘the_date’ is closed to new replies.