The PHP date('W')
function will never1 return 0.
Look it up in the source code of PHP, ext/date/php_date.c.
Slightly formatted around line 950-1000:
timelib_sll isoweek, isoyear;
int weekYearSet = 0;
...
/* week */
case 'W':
if(!weekYearSet) {
timelib_isoweek_from_date(t->y, t->m, t->d, &isoweek, &isoyear);
weekYearSet = 1;
}
length = slprintf(buffer, 32, "%02d", (int) isoweek); break; /* iso weeknr */
What is timelib_isoweek_from_date? Well... looking at the logic in ext/date/lib/dow.c, from line 82 it can be concluded that the week number varies from 1 to 53:
/* Find if Y M D falls in YearNumber Y-1, WeekNumber 52 or 53 */
...
/* 8. Find if Y M D falls in YearNumber Y+1, WeekNumber 1 */
...
/* 9. Find if Y M D falls in YearNumber Y, WeekNumber 1 through 53 */
If you do not believe me, look in the code yourself:
1) "Never" means "as long as there is no bug in PHP".