James Simpson
James Simpson

Reputation: 13688

How do I check for the first saturday of the month in PHP?

I need to make a simple if statement for a daily cron job to check if today is the first saturday of the month. How would I modify the following code to do that instead of just running on the 1st of every month?

if (date("j") == 1) {
    // run cron here
}

Upvotes: 0

Views: 344

Answers (2)

Arunabh Das
Arunabh Das

Reputation: 14352

            if  ((date("D")=="Sat") && (date("j")<=7)){

            }

Upvotes: 1

Sjoerd
Sjoerd

Reputation: 75588

The first saturday of the month is the saturday where the day number is 7 or less.

Upvotes: 5

Related Questions