<?php
/**
* Get Localized month name
* @param int $month
* @param string $locale
* @param string $format
* @return string
*/
function getLocalizedMonthName($month, $locale, $format = "LLLL")
{
$dateFormatter = new IntlDateFormatter($locale, IntlDateFormatter::FULL, IntlDateFormatter::FULL);
$dateFormatter->setPattern($format);
return $dateFormatter->format(mktime(0, 0, 0, $month));
}
$locales = ['pl_PL', 'en-US'];
foreach ($locales as $locale) {
foreach (range(1, 12) as $monthNumber) {
echo $monthNumber . " - " . getLocalizedMonthName($monthNumber, $locale) . PHP_EOL;
}
echo PHP_EOL . PHP_EOL;
}
preferences:
31.16 ms | 402 KiB | 5 Q