getTimestamp() - $start_time_dt->getTimestamp())); $start_tag = ''; $end_tag = ''; $unit = null; $div = 1; if ($trip_start_difference < $minute) { $unit = 'second'; } else if ($trip_start_difference < $hour) { $div = $minute; $unit = 'minute'; } else if ($trip_start_difference < $day) { $div = $hour; $unit = 'hour'; } else if ($trip_start_difference < $week) { $div = $day; $unit = 'day'; } else if ($trip_start_difference < $month) { $div = $week; $unit = 'week'; } else if ($trip_start_difference < $year) { $div = $month; $unit = 'month'; } else { $div = $year; $unit = 'year'; } return "{$start_tag}" . ( floor ( $trip_start_difference / $div ) ) . " {$unit}" . ( ( floor ( $trip_start_difference / $div ) > 1 ) ? 's' : '' ) . " ago{$end_tag}"; } }