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).
这篇关于一年中的每个星期?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:一年中的每个星期?
基础教程推荐
- 如何替换eregi() 2022-01-01
- PHP 类:全局变量作为类中的属性 2021-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
- 在PHP中根据W3C规范Unicode 2022-01-01
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
- 如何在 Laravel 中使用 React Router? 2022-01-01
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
