- // If we have a specific year, use it to calculate number of weeks.
- $date = new DateTime();
- $date->setISODate( $_year, 53 );
- $week_count = $date->format( "W" ) === "53" ? 53 : 52;
+ /*
+ * If we have a specific year, use it to calculate number of weeks.
+ * Note: the number of weeks in a year is the date in which Dec 28 appears.
+ */
+ $week_count = date( 'W', mktime( 0, 0, 0, 12, 28, $_year ) );