Displayed Date
I Have a site on which I am working on it right now. it has 2 languages EN and AR. Now the problem is that in arabic Site dates are shown in hijri format but I want to show it as gregorian format.
for example Date in en site looks like this : 31 July 2016 but same date in arabic site is Displayed like شوال 26, 1437 I want to display all the dates as en site format that is in english
if there any setting available Please do let me know
Hi Haresh,
First solution is to create language with specific ar culture.(For example ar-AE) Because in .Net many arabic cultures has Gregorian calendar.
Culture:ar; Year:1438Culture:ar-001; Year:2017Culture:ar-AE; Year:2017Culture:ar-BH; Year:2017Culture:ar-DJ; Year:2017Culture:ar-DZ; Year:2017Culture:ar-EG; Year:2017Culture:ar-ER; Year:2017Culture:ar-IL; Year:2017Culture:ar-IQ; Year:2017Culture:ar-JO; Year:2017Culture:ar-KM; Year:2017Culture:ar-KW; Year:2017Culture:ar-LB; Year:2017Culture:ar-LY; Year:2017Culture:ar-MA; Year:2017Culture:ar-MR; Year:2017Culture:ar-OM; Year:2017Culture:ar-PS; Year:2017Culture:ar-QA; Year:2017Culture:ar-SA; Year:1438Culture:ar-SD; Year:2017Culture:ar-SO; Year:2017Culture:ar-SS; Year:2017Culture:ar-SY; Year:2017Culture:ar-TD; Year:2017Culture:ar-TN; Year:2017Culture:ar-YE; Year:2017
Second approach is to create extension for proper datetime formatting and change your widget templates.
public static class DateTimeExtension public static string ToStringGregorianCalendar(this DateTime dt, string format) var culture = new CultureInfo(Thread.CurrentThread.CurrentUICulture.Name); GregorianCalendar calendar = new GregorianCalendar(); culture.DateTimeFormat.Calendar = calendar; return dt.ToString(format, culture);
And in widget templates you can use it like that:
@dateTime.ToStringGregorianCalendar("dd/MM/yyyy")