Cakephp 3 i18nFormat 字符串表示指定日期的周数

Cakephp 3 i18nFormat string for the number of weeks in a specified date

如何获取 cakephp 3 中特定日期的周数?

$this->mydate->i18nFormat('yyyy-MM-dd') 将显示年月日。

但是周数的字符串格式呢? 谢谢

仔细查看 Cake\I18n\Time::i18nFormat() 的文档,它告诉您可以作为格式传递什么,以及在哪里可以找到可接受的格式模式列表:

[...] You can either pass IntlDateFormatter constants as the first argument of this function, or pass a full ICU date formatting string as specified in the following resource: https://unicode-org.github.io/icu/userguide/format_parse/datetime/#datetime-format-syntax.

Cookbook > Date & Time > Formatting > Cake\I18n\Time::i18nFormat()

长话短说,一年中第几周的模式字母是 w,如果您想要一个前导零,则 ww,而每个月的第几周是 [=13] =] 或 WW.