Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End WordPress comments “time ago” feature

  • This topic is empty.
Viewing 1 post (of 1 total)
  • Author
    Posts
  • #41763

    Hey guys.

    I’m using this code to show relative comment time, but only if the comment is less than a week old. Otherwise it should show the full date, including the year if it was posted in a year other than the current one.


    if ( get_comment_time('U') > date('U') - 7*60*60*24 ) {
    echo human_time_diff( get_comment_time('U'), current_time('timestamp') ) . ' ago';
    } elseif ( get_comment_date('Y') == date('Y') ) {
    comment_date('F j');
    } else {
    comment_date('F j, Y');
    } ?>

    It works, but I’m having a problem with the “Live Comment Preview” plugin. In it, the “time ago” is displayed as a seemingly random number of days ago…over a million every time.

    How can I improve the code to make it just echo the standard date in the Comment Preview box?

    Thanks.

Viewing 1 post (of 1 total)
  • The forum ‘Back End’ is closed to new topics and replies.