Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9020355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:59:44+00:00 2026-06-16T04:59:44+00:00

On my Windows development machine, I have set the locale to ita : setlocale(LC_TIME,

  • 0

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)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T04:59:45+00:00Added an answer on June 16, 2026 at 4:59 am

    From the reference, some month formatting codes:

    Symbol     Meaning             Example:            
    
    M          month in year       M or MM    09       
                                   MMM        Sept     
                                   MMMM       September
                                   MMMMM      S        
    

    The PHP function to set the format is: IntlDateFormatter::setPattern, some examples:

    class LocaleDateFormat
    {
        private $locale;
        private $pattern;
    
        public function __construct($pattern, $locale = 'en_US') {
            $this->setLocale($locale);
            $this->setPattern($pattern);
        }
    
        public function setLocale($locale) {
            $this->locale = $locale;
        }
    
        public function setPattern($pattern) {
            $this->pattern = $pattern;
        }
    
        public function localeFormat($locale, $date) {
            $this->setLocale($locale);
            return $this->format($date);
        }
    
        public function format($date) {
            $formatter = new IntlDateFormatter($this->locale, IntlDateFormatter::FULL, IntlDateFormatter::FULL);
            $formatter->setPattern($this->pattern);
            return $formatter->format($date);
        }
    }
    
    $dateFormat = new LocaleDateFormat('MMMM'); # Long Month Names
    
    $date = new DateTime(); # Now
    
    $locales = ["en_US", "de_DE", "sv_SE", "ru_RU"];
    foreach ($locales as $i => $locale) {
        $month = $dateFormat->localeFormat($locale, $date);
        printf("%d. %s - %s\n", $i+1, $locale, $month);
    }
    

    Output:

    1. en_US - December
    2. de_DE - Dezember
    3. sv_SE - december
    4. ru_RU - декабря
    

    For a list of locales see here:

    • List of available collators in PHP?

    The actual example for the short monthnames across different locales:

    $locales    = ["en_US", "de_DE", "sv_SE", "ru_RU", 'it', 'it_IT', 'it_CH'];
    $dateFormat = new LocaleDateFormat('MMM'); # Short Month Names
    
    $date = new DateTime(); # Now
    
    foreach (range(1, 12) as $monthNumber)
    {
        $date->setDate(2012, $monthNumber, 1);
    
        printf("%02d:    ", $monthNumber);
    
        foreach ($locales as $locale)
        {
            $monthLabel = $dateFormat->localeFormat($locale, $date);
            $pad = str_repeat(' ', max(0, 8 - mb_strlen($monthLabel, 'UTF-8')));
            printf("%s: %s%s  ", $locale, $monthLabel, $pad);
        }
    
        echo "\n";
    }
    

    Exemplary output:

    01:    en_US: Jan       de_DE: Jan       sv_SE: jan       ru_RU: янв.      it: gen       it_IT: gen       it_CH: gen       
    02:    en_US: Feb       de_DE: Feb       sv_SE: feb       ru_RU: февр.     it: feb       it_IT: feb       it_CH: feb       
    03:    en_US: Mar       de_DE: Mär       sv_SE: mar       ru_RU: марта     it: mar       it_IT: mar       it_CH: mar       
    04:    en_US: Apr       de_DE: Apr       sv_SE: apr       ru_RU: апр.      it: apr       it_IT: apr       it_CH: apr       
    05:    en_US: May       de_DE: Mai       sv_SE: maj       ru_RU: мая       it: mag       it_IT: mag       it_CH: mag       
    06:    en_US: Jun       de_DE: Jun       sv_SE: jun       ru_RU: июня      it: giu       it_IT: giu       it_CH: giu       
    07:    en_US: Jul       de_DE: Jul       sv_SE: jul       ru_RU: июля      it: lug       it_IT: lug       it_CH: lug       
    08:    en_US: Aug       de_DE: Aug       sv_SE: aug       ru_RU: авг.      it: ago       it_IT: ago       it_CH: ago       
    09:    en_US: Sep       de_DE: Sep       sv_SE: sep       ru_RU: сент.     it: set       it_IT: set       it_CH: set       
    10:    en_US: Oct       de_DE: Okt       sv_SE: okt       ru_RU: окт.      it: ott       it_IT: ott       it_CH: ott       
    11:    en_US: Nov       de_DE: Nov       sv_SE: nov       ru_RU: нояб.     it: nov       it_IT: nov       it_CH: nov       
    12:    en_US: Dec       de_DE: Dez       sv_SE: dec       ru_RU: дек.      it: dic       it_IT: dic       it_CH: dic      
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a development machine A and a test server B. A runs Windows,
I have upgraded to PHP 5.3 on a development machine (Windows 7 box). php-v
I have an asp.net application running on my development machine (windows 7 ultimate, IIS
I have two machines I work on: Windows Client (Development Machine) Linux Web Server
Which OS would you recommend for a development machine: Windows Server 2008 R2 or
I'm using a Windows Server 2008 x64 R2 machine as a development box. Amongst
I have SVN running on my main windows development box on my home network.
I am just starting off Windows OEM development and have come across these two
I'm trying to set up a Windows-based web server, but do the development work
I have a windows machine trying to access the IIS server that has windows

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.