i want a php function to convert a unix time stamp to like this:
15 seconds
or
45 minutes
or
3 hours
and not like this : 2sec
PHP doesn't have a built-in function to do it for you, so you'd have to do it by hand. This function will get the difference in days, hours, minutes, or seconds and return in the format 'X days/hours/minutes/seconds':
= 1) {
$how_log_ago = $days . ' day' . ($days != 1 ? 's' : '');
} else if ($hours >= 1) {
$how_log_ago = $hours . ' hour' . ($hours != 1 ? 's' : '');
} else if ($minutes >= 1) {
$how_log_ago = $minutes . ' minute' . ($minutes != 1 ? 's' : '');
} else {
$how_log_ago = $seconds . ' second' . ($seconds != 1 ? 's' : '');
}
return $how_log_ago;
?>