How many weeks ago in the month with PHP

Asked

Viewed 87 times

1

Staff need to know how to calculate how many weeks there are in a respective month with PHP.

What’s the best way to do that?

1 answer

1


An example in soen

$mes = 2;
$ano = 2016;
$days = cal_days_in_month(CAL_GREGORIAN, $mes, $ano);

$week_day = date("N", mktime(0,0,0,1, $mes, $ano));

$weeks = ceil(($days + $week_day) / 7);

echo $weeks;

Browser other questions tagged

You are not signed in. Login or sign up in order to post.