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

date_display_format will lead to exception for some format characters #35

Open
domsson opened this issue Mar 1, 2022 · 1 comment
Open

Comments

@domsson
Copy link

domsson commented Mar 1, 2022

The config option date_display_format is handed over to the PHP date() function, which accepts a certain list of format characters. However, when I tried to change this option to 'Y m', the page will throw an exception:

An exception has been thrown during the rendering of a template ("DateTime::__construct(): Failed to parse time string (2016 06) at position 5 (0): Unexpected character"). 

Which points to plugins/archives/templates/partials/archives.html.twig, line 5.

Also:

  • When using a slightly different string, 'Y-m' (dash between), it works as expected
  • When using Kanji, it will throw an exception again: '年Y月m'

The expected behavior is that any format character/ string, as outlined in the PHP documentation (see above) can be used for this option and no exception is thrown. At the very least, better documentation is needed to understand what format characters can be used or can't be used (and why).

@mahagr
Copy link
Member

mahagr commented Mar 1, 2022

DateTime only supports few predefined formats, so no, you cannot use arbitrary date strings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants