mercredi 18 mars 2020

How To check a given date is Second , Fourth Saturday or all Sunday are not By Using Carbon in Laravel

I need to use this function for checking Second, fourth Saturday and all other Sunday of a given date

private function checkforholidays($date_to_check=array()) {
    $problem_status = array();

    if(!empty($date_to_check)){
        foreach($date_to_check as $each_date){
            $format_date    = new Carbon($each_date);
            if($format_date->isWeekend()){
                array_push($problem_status, 'Weekend');
            }
            $data = AddHolidayModel::checkforholidays($format_date->format('Y-m-d')); 

            if(count($data)>0){
                foreach($data as $each_date){
                    array_push($problem_status, $each_date['holiday_description']);
                }
            }
        }
    }
    return $problem_status;
}

This function is working good for checking all weekends



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire