function date_weeks_in_year in Date 7
Same name and namespace in other branches
- 8 date_api/date_api.module \date_weeks_in_year()
- 5.2 date_api.module \date_weeks_in_year()
- 6.2 date_api.module \date_weeks_in_year()
- 6 date_api.module \date_weeks_in_year()
- 7.3 date_api/date_api.module \date_weeks_in_year()
- 7.2 date_api/date_api.module \date_weeks_in_year()
The number of calendar weeks in a year.
PHP week functions return the ISO week, not the calendar week.
Parameters
int $year:
Return value
int number of calendar weeks in selected year.
File
- date_api/
date_api.module, line 1482 - This module will make the date API available to other modules. Designed to provide a light but flexible assortment of functions and constants, with more functionality in additional files that are not loaded unless other modules specifically include them.
Code
function date_weeks_in_year($year) {
$date = new DateObject($year + 1 . '-01-01 12:00:00', 'UTC');
date_modify($date, '-1 day');
return date_week($date
->format('Y-m-d'));
}