1. Go to this page and download the library: Download weblabormx/easy-time library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
$time = EasyTime::createFromFormat('2:10:30:00');
$time->second; // 0
$time->getSeconds(); // 210600 (Total seconds in all that time)
$time->minute; // 30
$time->getMinutes(); // 3510 (Total minutes in all that time)
$time->hour; // 10
$time->getHours(); // 58.5 (Total hours in all that time)
$time->day; // 2
$time->getDays(); // 2.42 (Total days in all that time)
$time->format(); // '58:30:00'
$time->format('full'); // '2:10:30:00'
$time->format('short'); // '30:00'
// First way
$sum = EasyTime::sum('00:30:30', '01:03:05'); // 01:33:35
// Second Way
$time = EasyTime::createFromFormat('00:30:30');
$time2 = EasyTime::createFromFormat('01:03:05');
$time = $time->addTime($time2); // 01:33:35
// First way
$sum = EasyTime::rest('02:30:30', '01:03:05'); // 01:27:25
// Second Way
$time = EasyTime::createFromFormat('02:30:30');
$time2 = EasyTime::createFromFormat('01:03:05');
$time = $time->subTime($time2); // 01:27:25