How to get number of week for specific date in cakephp 3
?
$this->mydate->i18nFormat('yyyy-MM-dd')
will display year-month-date.
But what about string format for week number? Thanks.
Have a closer look at the docs for Cake\I18n\Time::i18nFormat()
, it tells you what you can pass as the format, and where to find a list of the accepted formatting patterns:
[...] 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()
So long story short, the pattern letter for the week of the year is w
, or ww
if you want a leading zero, and for the week of the month it's W
or WW
.