Solution

Put the code bellow in your theme’s 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');

}

To use it simply echo it like in the code bellow.

echo time_ago();

Thanks to upThemes for this little snippet.

Our WordPress themes
We have a few WordPress themes that we would like you to take a look at if you want.
check out the portfolio