Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP date - get name of the months in local language

I have this part of the function, which gives me name of the months in English. How can I translate them to my local language (Serbian)?

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

Where $i is the number of the month (values 1 - 12). See also PHP:mktime.

like image 353
Sasha Avatar asked Dec 12 '12 17:12

Sasha


1 Answers

You should use setlocale():

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

In this case it would set it to French. For 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)
like image 192
MAXIM Avatar answered Sep 21 '22 08:09

MAXIM