Is there a (native) year-sensitive alternative to the PHP date ("W")?
No no.
According to official sources, the first calendar week of the year begins on the first Monday of the year.
I am not sure what official sources you have in mind.
PHP date("W") returns the week number in accordance with ISO 8601. As an international standard, ISO 8601 is considered one of perhaps many "official sources". If its definition of week numbers does not match your application, you can use whatever you like.
If you use the non-standard definition of βfirst week of the yearβ or if you use an official source that has not been widely accepted, expect that you will have to write your own function to replace date("W") . (I'm sure you need to write a function.)
Date 2012-01-01 - Sunday. ISO 8601, Wikipedia , and php agree that the ISO week number for 2012-01-01 is 52.
ISO 8601 does not define week 0.
So, if the first day of the year is not Monday, this is not week 1!
Neither ISO nor Wikipedia speak of this. ISO 8601 defines week number 1 as the week in which the first year of the year is. In 2012, the first Thursday was January 5, so number 1 was from January 2 to January 8. 2012-01-01 was in the last week of the previous year in terms of ISO weeks.
If you want something else, you can play with arithmetic, division, etc. (For example, try dividing the date ("z") by 7. For example, you can save this data in a database and spend weeks as you like.
If you are dealing with reporting periods, I would almost certainly have saved this data in a table in the database. It is very easy to generate such data using a spreadsheet.
The text of the data in the table is much easier to check than the text of the php function, regardless of how simple the function is. And the data will certainly be the same for any program that accesses it, regardless of the language it is written in. (So, if your database ever has programs written in 5 different languages, you do not need to write access to it, and support 5 different functions to get the week number.)