45 min ago and 1 hr ago and 1 day ao code example
Example: function return time ago php
public function convert_time_to_days($date) {
$current_date = date("Y-m-d H:m:s");
$time = array();
$day = floor((strtotime($current_date) - strtotime($date)) / (60 * 60 * 24));
if ($day == 0) {
$hour = floor((strtotime($current_date) - strtotime($date)) / (60 * 60));
if ($hour == 0) {
$minute = floor((strtotime($current_date) - strtotime($date)) / (60));
$time = $minute . __d('course', "minutes ago");
} else {
$time = $hour . __d('course', "hours ago");
}
} else {
$time = $day . __d('course', "days ago");
}
return $time;
}