WordPress.org

Support

Support » How-To and Troubleshooting » Conditional date: compare with today date

Conditional date: compare with today date

  • Hi to all,

    I’m trying to display a conditional date in my listing artcile sidebar:

    If the article date = today date -> display hour.
    If the article date != today date -> display date.

    Actually, my post title is build like that: <?php the_time(‘d.m’); ?> – <?php the_title(); ?> My PHP

    My PHP knowledge are very poor, so I trying with this code:

    if(the_date("d.m") == the_time("d.m")) echo the_time("H:i");
    else echo the_time("d.m");

    Obviously, it doesn’t work… Anyone to help me?

    Thanks,

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Conditional date: compare with today date’ is closed to new replies.
Skip to toolbar