PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, May 17, 2022

[FIXED] How do I add ucwords() on IntlDateFormatter()?

 May 17, 2022     php     No comments   

Issue

[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

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)));


Answered By - aynber
Answer Checked By - Timothy Miller (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing