Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How do I add ucwords() on IntlDateFormatter()?

[PHP 8.0] I want to temporary change language just for displaying month as a word.
And this works:

$fmt = new \IntlDateFormatter('Fi_FI', NULL, NULL);
$fmt->setPattern('d MMM yyyy'); 
echo $fmt->format(new \DateTime($w_date));

This gives me

10 toukok. 2002

But I want it to say Toukok with uppercase on first letter.
So I found out that ucwords() should fix it but I got syntax when I tested

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

echo $fmt->ucwords(format(new \DateTime($w_date)));

Where and how should I place the ucwords() ?
Thanks.

>Solution :

ucwords should surround the whole command, since format is a function of $fmt, while ucwords is a function by itself.

echo ucwords($fmt->format(new \DateTime($w_date)));
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading