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

Custom date format not respecting parameters (PHP8.1) #1273

Open
campZero opened this issue Aug 25, 2023 · 2 comments
Open

Custom date format not respecting parameters (PHP8.1) #1273

campZero opened this issue Aug 25, 2023 · 2 comments

Comments

@campZero
Copy link

I have a calendar that should get its title from the selected month, which used to work in older versions of PHP, unfortunately strftime is deprecated and the replacement in F3 does not really work with custom parameters.

{{ Base::instance()->format('{0,date,custom,%B %Y}', @Date) }}
{{ Base::instance()->format('{0,date,custom,MMMM YYYY}', @Date) }}

with @Date being a timestamp, will return 1. August 2023, although it should return August 2023.

If I read the code correctly, the date portion does not accept custom parameters when in the php8.1 branch.
base.php@line1068

@ikkez
Copy link
Collaborator

ikkez commented Aug 28, 2023

Sadly, there's no replacement for the parameters of strftime. The IntlDateFormatter uses a whole set of different parameters. Also I'm wondering, having a custom format option would actually defeat the purpose of a unified formatter, wouldn't it? So shall we add the custom option back again, which will certainly fail when on 8.1+ without adjustments or just drop that feature and encourage devs to simply register a custom formatter, what do you think?

@iahim
Copy link

iahim commented Aug 28, 2023

We should stick to whatever the norm is now. In the end one can always write a small wrapper function to customize a date output.

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

3 participants