how to set 1 year date without saturday in while loop php

Solutions on MaxInterview for how to set 1 year date without saturday in while loop php by the best coders in the world

showing results for - "how to set 1 year date without saturday in while loop php"
Nola
14 Apr 2019
1// returned $date Y/m/d
2function work_days_from_date($days, $forward, $date=NULL) 
3{
4    if(!$date)
5    {
6        $date = date('Y-m-d'); // if no date given, use todays date
7    }
8
9    while ($days != 0) 
10    {
11        $forward == 1 ? $day = strtotime($date.' +1 day') : $day = strtotime($date.' -1 day');
12        $date = date('Y-m-d',$day);
13        if( date('N', strtotime($date)) <= 5) // if it's a weekday
14        {
15          $days--;
16        }
17    }
18    return $date;
19}
20