Find out the number of weeks in a year
Hello!
Help me find out the number of weeks in a year using php.
0
1 answers
$year='2014';//год
echo date('W',mktime(0,0,0,12,31,$year));
Writing great
function getCountWeek($year)
{
$date=date('w',mktime(0,0,0,12,31,$year));
$day=($date<4?31-$date:31);
return date('W',mktime(0,0,0,12,$day,$year))+($date<4?1:0);
}
Update
Who cares. According to ISO 8601, the first week is not the one that starts on the first of January, but the one that contains the first Thursday of the year. I'm in shock myself)
2
Author: Ale_x, 2014-11-27 06:37:03