How to get 3rd business day from now(today's date)?

I have a module of payments lookup. Where I need to check status of ACH payment after 3rd business day. Let me know how to get 3rd business day(exclude Staturday & Sunday) from now.

thanks in advance

Asked 06 Oct, 17 at 07:11 AM

Arjun Singh
Php date

Answer

Try this: 

function excludeWeekends($todaydate){
        // echo "Date: $todaydate";
        $startDate = new DateTime($todaydate);
        $date = date("m/d/Y", strtotime(" + 10 DAY"));
        $days = array();
        $end = new DateTime($date);
        $oneday = new DateInterval("P1D");
        foreach(new DatePeriod($startDate, $oneday, $end->add($oneday)) as $day) {
            $day_num = $day->format("N"); /* 'N' number days 1 (mon) to 7 (sun) */
            if($day_num < 6) { /* weekday */
                $days[] = $day->format("Y-m-d");
                if( count($days) == 4){
                    break;
                }
            } 
        } 
        return end($days);
    }

like