WordPress “Time Ago” Function?

  • # June 6, 2013 at 9:40 pm

    I found this snippet [http://css-tricks.com/snippets/php/time-ago-function/](http://css-tricks.com/snippets/php/time-ago-function/ “http://css-tricks.com/snippets/php/time-ago-function/”) .
    But I am not sure I can use it for WordPress…

    I’m I tried placing both codes into my functions.php file while using//

    < ?php time(); ?>

    on the template I’m using but when I refresh the page nothing is displayed…

    Can anyone help me get this working Please?

    # June 6, 2013 at 9:50 pm

    I found another post [http://www.jasonbobich.com/wordpress/a-better-way-to-add-time-ago-to-your-wordpress-theme/](http://www.jasonbobich.com/wordpress/a-better-way-to-add-time-ago-to-your-wordpress-theme/ “http://www.jasonbobich.com/wordpress/a-better-way-to-add-time-ago-to-your-wordpress-theme/”)

    At first it didn’t work at all. But I browsed through the comments to an old question I had posted long ago and someone finally replied with a fix to the issue!

    This was the fix//

    Try replacing:

    $newer_date = strtotime( $current_time );


    $newer_date = time();

    Works wonderfully :)

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

There's a whole bunch of content on CSS-Tricks.

Search for Stuff   •   Browse the Archives

Get the Newsletter ... or get the RSS feed