Hi,
I've tried to do the following
{{ '2020-01-01' | date_modify('-1 day') | format_datetime(pattern='dd MMMM Y', locale='en') }}
and its output is 31 December 2020 while I was expecting it to give me the year 2019, as the following code does
{{ '2020-01-01' | date_modify('-1 day') | date('d F Y') }}
For the records, it seems to be linked to the year passed. For instance, with 2017-01-01, the output will be correct.
That's because Y means "Year of the week" in intl formaters, that's why you get 2020 because the 31th of december is part of the first week of 2020. You get different result depending of the year because depending of the year it's either part of the last week of the year or part of the first week of the next year.
To get the year of the date you need to use y instead (https://unicode-org.github.io/icu-docs/apidoc/released/icu4c/classSimpleDateFormat.html#details).
Most helpful comment
That's because
Ymeans "Year of the week" in intl formaters, that's why you get 2020 because the 31th of december is part of the first week of 2020. You get different result depending of the year because depending of the year it's either part of the last week of the year or part of the first week of the next year.To get the year of the date you need to use
yinstead (https://unicode-org.github.io/icu-docs/apidoc/released/icu4c/classSimpleDateFormat.html#details).