PHP date - get name of the months in local language PHP date - get name of the months in local language php php

PHP date - get name of the months in local language


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)


You should use setlocale() and strftime():

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


Here is an example with IntlDateFormatter

$format = new IntlDateFormatter('sr_CS', IntlDateFormatter::NONE,               IntlDateFormatter::NONE, NULL, NULL, "MMM");$monthName = datefmt_format($format, mktime(0, 0, 0, $i));