Month by week of the year?(一年中的每个星期?)
问题描述
我正在尝试通过一年中的一周数和一年中的数来获取一年中的月份数.因此,例如第 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).
这篇关于一年中的每个星期?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:一年中的每个星期?


基础教程推荐
- 使用 scandir() 在目录中查找文件夹 (PHP) 2022-01-01
- Yii2 - 在运行时设置邮件传输参数 2022-01-01
- php中的PDF导出 2022-01-01
- 主题化 Drupal 7 的 Ubercart “/cart"页 2021-01-01
- Web 服务器如何处理请求? 2021-01-01
- php 7.4 在写入变量中的 Twig 问题 2022-01-01
- PHPUnit 的 Selenium 2 文档到底在哪里? 2022-01-01
- 如何在数学上评估像“2-1"这样的字符串?产生“1"? 2022-01-01
- 将变量从树枝传递给 js 2022-01-01
- php中的foreach复选框POST 2021-01-01