0

2019-03-01 to 2019-04-04 remove Saturday and Sunday between two dates and count total Days

Lalit Kumar
  • 256
  • 2
  • 14
  • I don't think it's a duplicate, since it is addressed for Laravel, which uses extensively Carbon, a nice wrapper around Dates. So the answer to this is achieved with few lines of code (have a look at my answer). – Leonardo Rossi Apr 30 '19 at 07:40

1 Answers1

2

From Carbon Docs

CarbonPeriod::macro('countWeekdays', function () {
    return $this->filter('isWeekday')->count();
});
echo CarbonPeriod::create('2019-03-01', '2019-04-04')->countWeekdays();
Leonardo Rossi
  • 2,922
  • 2
  • 20
  • 28