Get the complete month name in English

前端 未结 6 520
予麋鹿
予麋鹿 2021-01-17 07:31

I use DateTime.Now.ToString(\"MMMM\") in order to get the current month\'s full name. It works well, but I get it in Hebrew.
Is there an option to

6条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-17 08:08

    you can use CultureInfo.CreateSpecificCulture(CultureName) to get month name in different languages.

    Refer this

    Creates a CultureInfo that represents the specific culture that is associated with the specified name.

    string MonthName =  DateTime.Now.ToString("MMMM", CultureInfo.CreateSpecificCulture(CultureName));
    

    For a list of predefined culture names, see the National Language Support (NLS) API Reference at the Go Global Developer Center

    //    CULTURE                                              SPECIFIC CULTURE
    //                 Invariant Language (Invariant Country)  
    //    af           Afrikaans                               af-ZA
    //    am           Amharic                                 am-ET
    //    ar           Arabic                                  ar-SA
    //    arn          Mapudungun                              arn-CL
    //    as           Assamese                                as-IN
    //    az           Azerbaijani                             az-Latn-AZ
    //    az-Cyrl      Azerbaijani (Cyrillic)                  az-Cyrl-AZ
    //    az-Latn      Azerbaijani (Latin)                     az-Latn-AZ
    //    ba           Bashkir                                 ba-RU
    //    be           Belarusian                              be-BY
    //    bg           Bulgarian                               bg-BG
    //    bn           Bengali                                 bn-IN
    //    bo           Tibetan                                 bo-CN
    //    br           Breton                                  br-FR
    //    bs           Bosnian                                 bs-Latn-BA
    //    bs-Cyrl      Bosnian (Cyrillic)                      bs-Cyrl-BA
    //    bs-Latn      Bosnian (Latin)                         bs-Latn-BA
    //    ca           Catalan                                 ca-ES
    //    co           Corsican                                co-FR
    //    cs           Czech                                   cs-CZ
    //    cy           Welsh                                   cy-GB
    //    da           Danish                                  da-DK
    //    de           German                                  de-DE
    //    dsb          Lower Sorbian                           dsb-DE
    //    dv           Divehi                                  dv-MV
    //    ...
    //    ta           Tamil                                   ta-IN
    //    te           Telugu                                  te-IN
    //    tg           Tajik                                   tg-Cyrl-TJ
    //    tg-Cyrl      Tajik (Cyrillic)                        tg-Cyrl-TJ
    //    th           Thai                                    th-TH
    //    tk           Turkmen                                 tk-TM
    //    tn           Setswana                                tn-ZA
    //    tr           Turkish                                 tr-TR
    //    tt           Tatar                                   tt-RU
    //    tzm          Tamazight                               tzm-Latn-DZ
    //    tzm-Latn     Tamazight (Latin)                       tzm-Latn-DZ
    //    ug           Uyghur                                  ug-CN
    //    uk           Ukrainian                               uk-UA
    //    ur           Urdu                                    ur-PK
    //    uz           Uzbek                                   uz-Latn-UZ
    //    uz-Cyrl      Uzbek (Cyrillic)                        uz-Cyrl-UZ
    //    uz-Latn      Uzbek (Latin)                           uz-Latn-UZ
    //    vi           Vietnamese                              vi-VN
    //    wo           Wolof                                   wo-SN
    //    xh           isiXhosa                                xh-ZA
    //    yo           Yoruba                                  yo-NG
    //    zh           Chinese                                 zh-CN
    //    zh-CHS       Chinese (Simplified) Legacy             zh-CN
    //    zh-CHT       Chinese (Traditional) Legacy            zh-HK
    //    zh-Hans      Chinese (Simplified)                    zh-CN
    //    zh-Hant      Chinese (Traditional)                   zh-HK
    //    zu           isiZulu                                 zu-ZA
    

提交回复
热议问题