On my Windows development machine, I have set the locale to ita:
setlocale(LC_TIME, 'ita');
echo strftime('%b'); // dic
While (I suppose, can’t test right now) on a *nix system, I should use it:
setlocale(LC_TIME, 'it');
If I try to set it on my Windows it doesn’t work, printing Dec.
It seems I can’t rely on setlocale(), so I should use IntlDateFormatter as suggested by @hakre. However, I can find the constant that gives me the month name and the short one:
IntlDateFormatter::NONE (integer)
Do not include this element
IntlDateFormatter::FULL (integer)
Completely specified style (Tuesday, April 12, 1952 AD or 3:30:42pm PST)
IntlDateFormatter::LONG (integer)
Long style (January 12, 1952 or 3:30:32pm)
IntlDateFormatter::MEDIUM (integer)
Medium style (Jan 12, 1952)
IntlDateFormatter::SHORT (integer)
Most abbreviated style, only essential data (12/13/52 or 3:30pm)
From the reference, some month formatting codes:
The PHP function to set the format is:
IntlDateFormatter::setPattern, some examples:Output:
For a list of locales see here:
The actual example for the short monthnames across different locales:
Exemplary output: