1. Go to this page and download the library: Download cmixin/enhanced-period 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/ */
cmixin / enhanced-period example snippets
use Carbon\CarbonPeriod;
use Cmixin\EnhancedPeriod;
CarbonPeriod::mixin(EnhancedPeriod::class); // This line is not needed if you use Laravel default auto-discovery.
// Use toEnhancedPeriod to convert `Carbon\CarbonPeriod` objects to `Spatie\Period\Period` ones
$a = CarbonPeriod::create('2018-01-01', '2018-01-10')->toEnhancedPeriod();
$b = CarbonPeriod::create('2018-01-15', '2018-01-31')->toEnhancedPeriod();
// Use fromEnhancedPeriod to convert `Spatie\Period\Period` objects to `Carbon\CarbonPeriod` ones
echo CarbonPeriod::fromEnhancedPeriod($a->gap($b));
// Or you can directly call gap() or most of the other `Spatie\Period\Period` methods directly on `Carbon\CarbonPeriod`:
$a = CarbonPeriod::create('2018-01-01', '2018-01-10');
$b = CarbonPeriod::create('2018-01-15', '2018-01-31');
// It will use `Spatie\Period\Period::gap` and automatically convert the result to `Carbon\CarbonPeriod`
echo $a->gap($b);