Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(common/twig): new filter ems_date #1102

Merged
merged 1 commit into from
Dec 9, 2024

Conversation

Davidmattei
Copy link
Member

Q A
Bug fix? n
New feature? y
BC breaks? n
Deprecations? n
Fixed tickets? n
Documentation? y

Using the normal twig date filter will throw exceptions if your format is 'strange'

{{ '31/12/1998 0:00:00'|date  }} {# throws exception "Failed to parse time string (31/12/1998 0:00:00) at position 0 (3): Unexpected character" #}

Now we can use the new ems_date filter which will use the DateTime standard for creating a true \DateTimeImmutable object

{{ '31/12/1998 0:00:00'|ems_date('j/m/Y H:i:s').format('d-m-Y H:i:s') }} {# output = 31-12-1998 00:00:00 #}

@Davidmattei Davidmattei merged commit e27af34 into ems-project:5.x Dec 9, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants