In some languages ​​I get: 2012 j...">

Strftime creates first letter (uppercase) in PHP

I have a code:

<?php echo strftime("%Y %B %e, %A")?>

In some languages ​​I get:

2012 junio 3, domingo

I want the first letter of all words to be capitalized (capital), so it will look like this:

2012 Junio ​​3, Domingo

I did not find an answer on the Internet, does anyone have an idea? :)

+5
source share
5 answers

Try echo ucwords(strftime("%Y %B %e, %A"));

http://php.net/manual/en/function.ucwords.php

+14
source
echo ucwords(strftime("%Y %B %e, %A"));
+4
source
$ php -a
Interactive shell

php > $x = strftime("%Y %B %e, %A");
php > $str = explode(" ", $x);
php > foreach ($str as $i) { print ucfirst($i) . " "; };
2012 June  3, Sunday 
php > 
0

:

strftime('<span style="text-transform: capitalize;">%Y %B %e, %A</span>')

echo '<span style="text-transform: capitalize;">' . strftime('%Y %B %e, %A') . '</span>';

This way you can choose which words to use. In your case it ucwordsworks, I think, since you want all your words to start with an uppercase.

0
source

All Articles