Incorrect monthly impressions for July when culture is set to ar-AE in asp.net web form

The website shows the wrong month for julyin Arabic, this is an Arabic website developed in the asp.net web form, and the culture is correctly set to " ar-AE ", and the date of the event shows the correct month in local but in production it shows the month that belongsEgyptian culture

The date in the database is saved as smalldatetimein this format2017-07-25 00:00:00

The wrong month for July

The correct month on the local host: 25 ูŠูˆู„ูŠูˆ 2017

Wrong production month: 25 ูŠูˆู„ูŠู‡ 2017

<asp:Label  ID="lblDate"  runat="server"  Text='<%# FormatDate(Eval("PublishDate")) %>'>
</asp:Label>

protected string FormatDate(object dt) {
  string date = String.Format("{0:MMMM dd, yyyy}", dt);
  date = String.Format("{0:dd MMMM yyyy}", dt);
  // Response.Write(date + "<br/>");
  return date;
}

The culture is correctly established in the UAE

protected override void InitializeCulture() {
  String lang = "ar-AE";
  CultureInfo ci = System.Threading.Thread.CurrentThread.CurrentUICulture;
  // Call function to detect Language and assign  to session variable
  Thread.CurrentThread.CurrentCulture = new CultureInfo(lang);
  Thread.CurrentThread.CurrentUICulture = new CultureInfo(lang);

  base.InitializeCulture();
}

What could be the reason, maybe it's the production server itself?

, , .

. , IIS. , . , , , , , - . Windows 7, .

. , JULY ูŠูˆู„ูŠู‡. . .

https://dotnetfiddle.net/ZAOJ7H

+4
2

DateTime, :

DateTime dt = DateTime.Parse("2017-07-25 00:00:00");

string arabicMonth = new CultureInfo("ar-AE").DateTimeFormat.GetMonthName(dt.Month);

ูŠูˆู„ูŠู‡ ูŠูˆู„ูŠูˆ, , - Windows- .

, locale.nls, %WINDIR%\System32\locale.nls, , , , .

NLS , , . AFAIK, Microsoft KB981981 Windows 7 Server 2008 R2, ( ):

Windows 7 32- (KB981981) - 5/24/2010

Windows 7 64- (KB981981) - 5/24/2010

. , . - , jQuery datepicker, ูŠูˆู„ูŠูˆ .

PS: zahed OP -

DateTime.Parse("2017-07-25 00:00:00").ToString("dd dddd , MMMM, yyyy", new CultureInfo("ar-AE"))

25 ุงู„ุซู„ุงุซุงุก , ูŠูˆู„ูŠู‡, 2017 (.. ูŠูˆู„ูŠู‡), , Windows, .

:

Windows Server 2010

datetime #?

:

. -

+2

:

<div>
    <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
    <asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButton1_Click">LinkButton</asp:LinkButton>
</div>

#:

protected void LinkButton1_Click(object sender, EventArgs e)
{
    Label1.Text = DateTime.Parse("2017-07-25 00:00:00").ToString("dd dddd , MMMM, yyyy", new CultureInfo("ar-AE"));
}

:

, (, ).

: .

0

Source: https://habr.com/ru/post/1687290/


All Articles