<?php
$date2='2022-08-1 2:10:00';
date_default_timezone_set('Asia/Karachi');
$date1 = date("Y-m-d H:i:s");
$timestamp1 = strtotime($date1);
$timestamp2 = strtotime($date2);
$posted_time_hours = round((abs($timestamp2 - $timestamp1))/(60*60)) ;
if(($posted_time_hours) >= 24){
$posted_time_hours = round($posted_time_hours/24) . " day(s) ago";
}
else{
$posted_time_hours = $posted_time_hours . " hour(s) ago";
}
echo $posted_time_hours;
?>