WordPress.org

Ready to get started?Download WordPress

Forums

human friendly time for comments (7 posts)

  1. rec19
    Member
    Posted 4 months ago #

    I found this code from codex.wordpress to display human friendly time in comments:

    <?php echo human_time_diff( get_comment_time('U'), current_time('timestamp') ) . ' ago'; ?>

    How can I add this in functions.php ?

  2. alchymyth
    The Sweeper & Moderator
    Posted 4 months ago #

    How can I add this in functions.php ?

    edit functions.php of your theme;

    http://codex.wordpress.org/Editing_Files

    why in functions.php?
    where do you want to show the time?
    what theme are you using?

    http://codex.wordpress.org/Forum_Welcome#Include_as_much_information_as_possible

  3. rec19
    Member
    Posted 4 months ago #

    Thanks for the reply

    I am using genesis framework but so far I have managed to kept all my php edits in functions.php.

    I would like the time to show in the comments where there is already a default date and time

  4. alchymyth
    The Sweeper & Moderator
    Posted 4 months ago #

    for any questions relating to the genesis framework, please contact studiopress for support.

    http://codex.wordpress.org/Forum_Welcome#Commercial_Products

  5. rec19
    Member
    Posted 4 months ago #

    One of my themes that I use is twenty fourteen though, its just most of the themes I use are Genesis. Aslo (I think) this has something to do with the wordpress core files so I was hoping 1 code snippet will work for all my child themes by putting it in function.php or an mu-plugin.

    I should have been clearer, I'm not sure how to get the below code to work in functions.php because it is a snippet to replace another code in one of the template files.

    <?php echo human_time_diff( get_comment_time('U'), current_time('timestamp') ) . ' ago'; ?>

  6. Saravanan
    Member
    Posted 4 months ago #

    I think adding the snippets will be theme specific and you might have to add them based on the theme. The wp-days-ago plugin might be of interest to you. You can check it out here.

  7. rec19
    Member
    Posted 4 months ago #

    Thanks for replying, I didn't realise there was a plugin for it, i'll give it a go.

Reply

You must log in to post.

About this Topic

Tags