一年中的每个星期?
我正在尝试通过一年中的一周数和一年中的数来获取一年中的月份数.因此,例如第 1 周在 1 月并返回 1,第 6 周在 2 月,所以我想要 2.
I'm trying to get the number of the month of the year by the number of a week of the year and the year. So for example week 1 is in january and returns 1, week 6 is in february so I want 2.
我尝试使用 date_parse_from_format('W/Y')
但没有成功(它给了我错误).
I tried to go with date_parse_from_format('W/Y')
but had no success (it's giving me errors).
有没有办法使用 date_parse_from_format()
还是有其他方法?
Is there any way to go with date_parse_from_format()
or is there another way?
推荐答案
print date("m",strtotime("2011-W6-1"));
(请注意,在 2011 年,一月有六周,所以第 6 周(根据某些定义)是在第 1 个月).
(noting that in 2011, January has six weeks so week 6 (by some definitions) is in month 1).
相关文章