WordPress.org

Ready to get started?Download WordPress

Forums

the_time() problems display Today, Yesterday (2 posts)

  1. bubazoo
    Member
    Posted 9 years ago #

    In my template, I'm trying to display:

    Today, June 17th, 2005
    Yesterday, June 16th, 2005
    Wednesday, June 15th, 2005

    to the template, but I seem to be having a problem with the_time() function.

    here is my code..

    <?
    $today = date("Ymd");
    $yesterday = date("Ymd", time() - 86400);
    $mtdate = the_time('Ymd');

    if ($mtdate==$today) {
    echo ('Today, ');
    the_time('F j, Y');
    }
    elseif ($mtdate==$yesterday) {
    echo ('Yesterday, ');
    the_time('F j, Y');
    }
    else {
    the_time('l, F j, Y');
    }
    ?>

    This therectically should work, but for some reason its displaying like this instead:

    20050617Friday, June 17th, 2005

    instead. Is there a way to fix this?

    thanks

  2. bubazoo
    Member
    Posted 9 years ago #

    nevermind, its

    $mtdate = get_the_time('Ymd');
    instead of
    $mtdate = the_time('Ymd');

    welllll, I was close...LOL

Topic Closed

This topic has been closed to new replies.

About this Topic