Lilly
Lilly

Reputation: 69

Date gives as result 2024 instead of 1924 Twig

In the database, I have following date: 1924-01-17, as a date-type, but when I render it as {{ person.BirthDate | date("d/m/Y") }}, it gives as a result 17/01/2024.

How can I solve the Year-problem?

Upvotes: 1

Views: 297

Answers (1)

eis
eis

Reputation: 53462

Twig documentation for date says:

The date filter accepts strings (it must be in a format supported by the strtotime function), DateTime instances, or DateInterval instances.

DateTime instance should do the trick, and based on comments it fixed this.

Upvotes: 2

Related Questions