PHP code example of rampesna / date-diff-calculator
1. Go to this page and download the library: Download rampesna/date-diff-calculator 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/ */
rampesna / date-diff-calculator example snippets
use Rampesna\DateDiffCalculator;
class ExampleController extends Controller
{
public function index(Request $request)
{
$permitStartDate = '2023-09-20 09:00:00';
$permitEndDate = '2023-10-10 18:00:00';
$dailyWorkingHours = 8;
$dateDiffCalculator = new DateDiffCalculator(
$dailyWorkingHours,
$permitStartDate,
$permitEndDate
);
$minutes = $dateDiffCalculator->calculate();
return response()->json(
$dateDiffCalculator->getDurationForHuman($minutes)
);
}
}