saturday and sunday will not count as number of days php mysql

Solutions on MaxInterview for saturday and sunday will not count as number of days php mysql by the best coders in the world

showing results for - "saturday and sunday will not count as number of days php mysql"
Victoria
26 Jul 2017
1$workdays = array();
2$type = CAL_GREGORIAN;
3$month = date('n'); // Month ID, 1 through to 12.
4$year = date('Y'); // Year in 4 digit 2009 format.
5$day_count = cal_days_in_month($type, $month, $year); // Get the amount of days
6
7//loop through all days
8for ($i = 1; $i <= $day_count; $i++) {
9
10        $date = $year.'/'.$month.'/'.$i; //format date
11        $get_name = date('l', strtotime($date)); //get week day
12        $day_name = substr($get_name, 0, 3); // Trim day name to 3 chars
13
14        //if not a weekend add day to array
15        if($day_name != 'Sun' && $day_name != 'Sat'){
16            $workdays[] = $i;
17        }
18
19}
20
21// look at items in the array uncomment the next line
22   //print_r($workdays);