2019-03-01 to 2019-04-04 remove Saturday and Sunday between two dates and count total Days
            Asked
            
        
        
            Active
            
        
            Viewed 1,471 times
        
    0
            
            
        - 
                    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 Answers
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
 
- 
                    
 - 
                    
 - 
                    How about if i want to get array of days excluding weekends ```CarbonPeriod::create('2019-03-01', '2019-04-04')->toArray();``` – Nov 19 '20 at 13:42