How to change date format and culture?

I need to change the culture of my string to Arabic.

this code:

<%# Eval("NewsDate","{0: dddd dd / MMMM / yyyy }").ToString() %> 

will show me the following results: sunday 01 / may / 1994

I tried to show it in Arabic, so it will look like this: Ψ§Ω„Ψ§Ψ­Ψ― 01 -Ω…Ψ§ΩŠΩˆ - 1994

 <%# Eval("NewsDate","{0: dddd dd / MMMM / yyyy }").ToString("{0}:",System.Globalization.CultureInfo.CreateSpecificCulture("ar-KW")) %> 

I added this line to my web.config:

 <globalization culture="ar-KW" uiCulture="ar-KW"/> 

but it does not work!

any suggestions please?

+4
source share
2 answers

If you need, you can change the culture for the current thread, so you do not need to do this for each call.

 Thread.CurrentThread.CurrentCulture = New CultureInfo("th-TH", False) 
0
source

Try this and let me know if everything is all right?

 protected string returnDate(DateTime dt) { System.Globalization.CultureInfo calture = new System.Globalization.CultureInfo("ar-KW"); System.Globalization.DateTimeFormatInfo dtf = calture.DateTimeFormat; dtf.Calendar = new System.Globalization.HijriCalendar(); dtf.ShortDatePattern = "dd/MM/yyyy"; dtf.MonthDayPattern = "MMMM"; return dt.ToString("dd/MMMM/yy", dtf); } 

and

Then call this function in

 <%# Eval("NewsDate", returnDate(NewsDate) %> 

thanks

0
source

All Articles