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.
Using FTP and PHP to get an array of file details such as size and…
Creating and using Laravel form requests to create cleaner code, separation and reusability for your…
Improving the default Laravel login and register views in such a simple manner but making…
Laravel validation for checking if a field value exists in the database. The validation rule…