If you want to get the minutes, hours, days, months between two dates in PHP this function is for you. Feel free to customize its return output to suit your needs as per the commented out time values.
function date_to_ago($old_date, $new_date){
$date1 = new DateTime($old_date);
$date2 = $date1->diff(new DateTime($new_date));
//$date2->days.' days
';
//$date2->y.' years
';
//$date2->m.' months
';
//$date2->d.' days
';
//$date2->h.' hours
';
//$date2->i.' minutes
';
//$date2->s.' seconds
';
return "$date2->i Minutes";
}
echo date_to_ago('2018-02-4 9:28:07','2018-02-4 10:29:34');//61 In the example i got the minutes between two date times with the difference being 61 minutes.
A drained and empty Kennington reservoir images from a drone in early July 2024. The…
Merrimu Reservoir from drone. Click images to view larger.
Some early September spring shots from a bushwalk, It is still too early for wildflowers.
I recently needed to clone over a smaller NVMe to a 2TB SK Hynix Platinum…
If you ever needed a simple solution in Laravel to delete an entire directory and…
How to enforce only one user to register or be registered in a Laravel web…