Getting year and week of year from PHP date() when week spans two years

前端 未结 1 1968
Happy的楠姐
Happy的楠姐 2021-01-05 08:40

I have run into an interesting issue using PHP\'s date() function. Haven\'t had any luck locating a discussion of this on SO or using Google, but maybe someone

1条回答
  •  孤独总比滥情好
    2021-01-05 09:44

    Darn, apparently I didn't re-read the documentation closely enough, the letter o was added in PHP 5.1.0:

    From the documentation for date():

    ISO-8601 year number. This has the same value as Y, except that if the ISO week number (W) belongs to the previous or next year, that year is used instead. (added in PHP 5.1.0)

    So my code should have been date("o-\WW");

    0 讨论(0)
提交回复
热议问题