Forums

php help (3 posts)

  1. aylee
    Member
    Posted 2 years ago #

    I want to create a conditional statement in a Wordpress theme and I don't know how to do it, syntax and all. This is actually the conditions I want:

    if (today's date > 10 + date of post)
    {...}
    else
    {...}

    Thanks!

  2. MattFroggett
    Member
    Posted 2 years ago #

    You could try the following:

    <?php echo date("d"); ?>

    That would echo the day of the month. As taken from the PHP manuel "Day of the month, 2 digits with leading zeros" 01 - 31. Then the if statment could be something like:

    <?php
    $date = date("d");
    if($date > 10 + *dateofpostcode*) {
    echo "True";
    } else {
    echo "False";
    }
    ?>

    I think that would work, but you would have to replace the *dateofpostcode* with the code that fetches the date of post from the database.

    Hope I have helped you.
    Thanks,
    Matt

  3. aylee
    Member
    Posted 2 years ago #

    thanks matt! i'll try it.

Topic Closed

This topic has been closed to new replies.

About this Topic