PHP date - get month name in local language
P粉515066518
P粉515066518 2023-08-24 10:04:47
0
2
507
<p>I have this part of the function which gives me the name of the month in English. How can I translate them into my local language (Serbian)? </p> <pre class="brush:php;toolbar:false;">$month_name = date('F', mktime(0, 0, 0, $i));</pre> <p>where <code>$i</code> is the month number (values ​​1 - 12). See also PHP:mktime. </p>
P粉515066518
P粉515066518

reply all(2)
P粉037215587

You should use setlocale() and strftime():

setlocale(LC_TIME, 'sr_CS');
$month_name = strftime('%B', mktime(0, 0, 0, $i));
P粉445714413

You should use setlocale():

setlocale(LC_TIME, 'fr_FR');
$month_name = date('F', mktime(0, 0, 0, $i));

In this example it will be set to French. In your case it should be one of the following:

  1. sr_BA - Serbian (Montenegro)
  2. sr_CS - Serbian (Serbia)
  3. sr_ME - Serbian (Serbia and Montenegro)
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!