how to calculate number of days in a week? for example 1st week in January 2014 has 4 days, so the function will return 4.
googled this, no answers to my need.
how to calculate number of days in a week? for example 1st week in January 2014 has 4 days, so the function will return 4.
googled this, no answers to my need.
$str = "January 1 2014 Sunday";
echo date("z", strtotime($str));
Output - 4
ps: works only for the first week of January of any year as follows from question.
pps: this is for 1st week of any month
$str = "February 1 2014";
echo date("z", strtotime($str . " Sunday")) - date("z", strtotime($str));
and for the last week
$str = "February 2014";
echo date("z", strtotime("last day of " . $str)) -
date("z", strtotime("last monday of " . $str));