6

Hi i am looking for method to transform English date in this format dd/MMM/yyyy to Arabic date

for example 18/Feb/2016 will be in Arabic ١٨/فبراير/٢٠١٦

Varda Elentári
  • 2,242
  • 6
  • 35
  • 55
Ayman
  • 842
  • 6
  • 16
  • 31
  • 1
    Have you tried anything yet? Questions asking us to find a tool, software library, or other off-site resource are off-topic – Sayse Feb 18 '16 at 16:25
  • You can specify the culture when parsing (`DateTime.Parse(String, IFormatProvider)`) and formatting (`DateTime.ToString(String, IFormatProvider)`). – juharr Feb 18 '16 at 16:28

2 Answers2

6

Try using something like this:

DateTime.Now.ToString("dd dddd , MMMM, yyyy", new CultureInfo("ar-AE"));

instead of the DateTime.Now just put whatever DateTime object you want to convert.

Varda Elentári
  • 2,242
  • 6
  • 35
  • 55
  • how to do it when I am formating date like this way TBDate.Text = Convert.ToDateTime(oraReder[2]).ToString("hh:mm:ss dd/MM/yyyy"); – sam Dec 11 '16 at 20:56
  • It should be something like this: `TBDate.Text = Convert.ToDateTime(oraReder[2]).ToString("hh:mm:ss dd/MM/yyyy", new CultureInfo("ar-AE"));` – Varda Elentári Dec 13 '16 at 18:53
  • format did not changed no errors nothing changed TBNextDate.Text = Convert.ToDateTime(oraReder[4]).ToString("hh:mm:ss dd/MM/yyyy", new CultureInfo("ar-AE")); – sam Dec 13 '16 at 19:29
  • 3
    It shows only month in Arabic while date and year values are shown in english digits. – Kasim Husaini Feb 01 '17 at 03:24
  • Even I thought it would solve the problem for me but only shows the month in Arabic and not the date and year. I am looking at a format like 01 Jan - 31 Jan, 2020. Any suggestions on how to the get everything converted to arabic? – ahjashish Sep 06 '21 at 09:59
1

Use CultureInfo class to convert date formats in different languages.

using System.Globalization;    
DateTime.UtcNow.ToString("dd dddd , MMMM, yyyy", new CultureInfo("ar-AE"));
Codemaker2015
  • 12,190
  • 6
  • 97
  • 81