WordPress Post Date in human readable format

Four months ago I was not able to print my posted date in  this format “18 days ago” in WordPress. But now I am able to so and thought why not share the solution through this blog.  🙂

Steps to convert the earlier date as shown in the above figure (22 July,2010) to 5 days ago:

  • Use the following code snippet in your fuction.php
      function rt_day_ago( $type = 'post' )
                {
                 $rt_misc = 'comment' == $type ? 'get_comment_time' : 'get_post_time';
                 return human_time_diff($rt_misc('U'), current_time('timestamp')) . " " . __('ago');
                }
  • Call the above function where we want to display these post pages as well as comment pages.

<?php echo rt_day_ago() ?>

For more information click here.

If you know some other way also to change the post timings, feel free to share it with me through your comments.

Published by Sneha Mutha

I am a Web Designer and love to create Creative presentations of content....:)