Get the complete month name in English

前端 未结 6 526
予麋鹿
予麋鹿 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:07

    You can pass a CultureInfo object as an argument DateTime.ToString():

    CultureInfo ci = new CultureInfo("en-US");
    var month = DateTime.Now.ToString("MMMM", ci);
    
    // alternatively you can use CultureInfo.InvariantCulture:
    var month = DateTime.Now.ToString("MMMM", CultureInfo.InvariantCulture);
    

提交回复
热议问题