wordpress by default writes the the date on posts, but how can I transform it to : “x” time ago ?? like 3 days ago, or 5 minutes ago ??

2 s
function k99_relative_time() {
$post_date = get_the_time('U');
$delta = time() - $post_date;
if ( $delta < 60 ) {
echo 'Less than a minute ago';
}
elseif ($delta > 60 && $delta < 120){
echo 'About a minute ago';
}
elseif ($delta > 120 && $delta < (60*60)){
echo strval(round(($delta/60),0)), ' minutes ago';
}
elseif ($delta > (60*60) && $delta < (120*60)){
echo 'About an hour ago';
}
elseif ($delta > (120*60) && $delta < (24*60*60)){
echo strval(round(($delta/3600),0)), ' hours ago';
}
else {
echo the_time('j\<\s\u\p\>S\<\/\s\u\p\> M y g:i a');
}
}
then put k99_relative_time()
; in theme file where you want this to appear.