'How can I check Saturday with date_create()->format('w') in a loop

How can I check Saturday.

I tried to do this

    for($j = $date_time ; (int)date_create($j)->format('w') <= 6 ; $j++){
    
    }

This error happen.

Symfony\Component\Debug\Exception\FatalThrowableError: Call to a member function format() on bool

When it

for($j = $date_time ; (int)date_create($j)->format('w') < 6 ; $j++){

}

Somehow it goes well.

How Can I check if $j is Saturday?

print_r("date_time");
print_r($date_time);

Result is :

2022-6-01
php


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source