Changing Date format to en-us while culture is fr-ca

后端 未结 6 718
[愿得一人]
[愿得一人] 2021-01-11 17:21

I\'m working on localizing a website in French. However I am not supposed to change the date format to French. It must remain as per en-us format even if the culture is set

6条回答
  •  猫巷女王i
    2021-01-11 17:57

    Thanks Guys !!!! Seems like your sugessions are working for me. I tried creating a custom culture which extends the features of fr-ca and changes its date format to en-us. Here is the code

    CultureInfo ci = new CultureInfo("fr-ca");
    DateTimeFormatInfo dateformat = new DateTimeFormatInfo();
    dateformat.FullDateTimePattern = "ffffdd, mmmm dd, yyyy h:mm:ss tt";// Date format of en-us
    ci.DateTimeFormat = dateformat;
    CultureAndRegionInfoBuilder obj = new CultureAndRegionInfoBuilder("fr-ca", CultureAndRegionModifiers.Replacement);
    obj.LoadDataFromCultureInfo(ci);
    obj.Register();
    

    Once the code registers new fr-ca, the date format of the fr-ca will be same as that of en-us. The code can be used in Page_Load.

提交回复
热议问题