一年中的每个星期? [英] Month by week of the year?

查看:22
本文介绍了一年中的每个星期?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过一年中的一周数和一年中的数来获取一年中的月份数.因此,例如第 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).

这篇关于一年中的每个星期?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆