Created
September 27, 2018 04:49
-
-
Save lomotech/a5767aea19215308a424d4dc983e8ef2 to your computer and use it in GitHub Desktop.
get date diff exclude multiple day
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Carbon\Carbon; | |
$dt = Carbon::create(2018, 9, 17); | |
$dt2 = Carbon::create(2018, 9, 24); | |
$holiday = ['2018-09-21']; | |
$offday = ['2018-09-22', '2018-09-21']; | |
$daysForExtraCoding = $dt->diffInDaysFiltered(function(Carbon $date) use ($holiday, $offday){ | |
return !in_array($date->toDateString(), $offday) && !in_array($date->toDateString(), $holiday); | |
}, $dt2); | |
dd($daysForExtraCoding); | |
return $daysForExtraCoding; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment