PHP date - get month name in local language
P粉515066518
2023-08-24 10:04:47
<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>
You should use
setlocale()
andstrftime()
:You should use
setlocale()
:In this example it will be set to French. In your case it should be one of the following:
sr_BA
- Serbian (Montenegro)sr_CS
- Serbian (Serbia)sr_ME
- Serbian (Serbia and Montenegro)