Twig: date format with localizeddate extension

2.6k views Asked by At

I have:

<div class="date">
{{ event.date|localizeddate('full', 'none', null, 'Europe/Moscow', 'd MMMM YYYY, EEEE') }}
</div>

Where event.date = '2016-12-30', MySQL DATE string.

When date localized, output is '30 December 2017, Friday'. I don't understand, why year is changed to 2017? Why that happening?

2

There are 2 answers

0
Quehnie On

Had the same issue in a recent project.

In the documentation it says Y stands for "year of "Week of Year"" and y is for the year.

http://userguide.icu-project.org/formatparse/datetime

0
PeterD On

try using this:

{{ event.date|date("m/d/Y")|localizeddate('full', 'none', null, 'Europe/Moscow', 'd MMMM YYYY, EEEE') }}