The first thing to do is to create the function. To do so, paste the following into your functions.php file:
function time_ago( $type = ‘post’ ) {
$d = ‘comment’ == $type ? ‘get_comment_time’ : ‘get_post_time’;
return human_time_diff($d(‘U’), current_time(‘timestamp’)) . ” ” . __(‘ago’);
}
Once done, you can use the function in your theme files:

echo time_ago();

By admin

Leave a Reply

Your email address will not be published. Required fields are marked *