WordPress.org

Forums

[resolved] Check if post is older than a certain date (3 posts)

  1. Nikolas
    Member
    Posted 5 years ago #

    Hello there, I am trying to create an IF statement that I want to check if the date of an article is older than a date I want. I am having some problems though.. any help appreciate.
    I am using j F Y to display the date of the article.

    <?php
          $date1 = "25 09 2009";
          $date2 = the_date('', '', '', FALSE);
    if ($date1 < $date2) {
    $valid1 = "yes";
    echo "$valid1"; } else {
    $valid2 = "no";
    echo "$valid2";}
          ?>
  2. MichaelH
    Member
    Posted 5 years ago #

    Assuming this is in a post loop, use this instead:

    $date1 = "2009-09-25"; //September 25, 2009
    $date2 = $post->post_date;
  3. Nikolas
    Member
    Posted 5 years ago #

    great it worked! thanks!!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags