if you are using type: timestamp and default current_timestamp() in your date column, then this should work fine.
<?php
// change this according to your system's timezone
date_default_timezone_set('Asia/Manila');
$date = new DateTime(date("Y-m-d H:i:s", strtotime($row['date'])));
$date_now = new DateTime(date("Y-m-d H:i:s"));
// this is used to compare the difference
$diff = $date_now->diff($date)->format('%Y%M%D%H%I%S');
// this is used to show the difference in time with different format
$show_time = $date_now->diff($date);
// 200 is equal to 00 year, 00 month, 00 day, 00 hour, 02 minutes, 00 second
if($diff < 200){ $HeaderDate = "Just now"; }
// 10000 is equal to 00 year, 00 month, 00 day, 01 hour, 00 minute, 00 second
elseif($diff < 10000){ $HeaderDate = $show_time->format("%i minutes ago"); }
// 20000 is equal to 00 year, 00, month 00 day, 02 hours, 00 minute, 00 second
elseif($diff < 20000){ $HeaderDate = "An hour ago"; }
// 1000000 is equal to 00 year, 00 month, 01 day, 00 hour, 00 minute, 00 second
elseif($diff < 1000000){ $HeaderDate = $show_time->format("%h hours ago ".$date->format('(g:i a)')); }
// 2000000 is equal to 00 year, 00 month, 02 days, 00 hour, 00 minute, 00 second
elseif($diff < 2000000){ $HeaderDate = " Yesterday ".$date->format("(g:i a)"); }
// 7000000 is equal to 00 year, 00 month, 07 days, 00 hour, 00 minute, 00 second
elseif($diff < 7000000){ $HeaderDate = $date->format('l (g:i a)'); }
// 100000000 is equal to 00 year, 01 month, 00 day, 00 hour, 00 minute, 00 second
elseif($diff < 100000000){ $HeaderDate = $show_time->format("%d days ago ").$date->format('(M. d, g:i a)'); }
// 2000000 is equal to 00 year, 02 months, 00 day, 00 hour, 00 minute, 00 second
elseif($diff < 200000000){ $HeaderDate = "Last month" . $date->format(' (M. d, g:i a)'); }
// 10000000000 is equal to 01 year, 00 month, 00 day, 00 hour, 00 minute, 00 second
elseif($diff < 10000000000){ $HeaderDate = $show_time->format("%m months ago") . $date->format(' (M. d, g:i a)'); }
else { $HeaderDate = $date->format('M. d, Y g:i a'); }
echo $HeaderDate;
?>