Displayed Date - Bugs & Issues - Bugs & Issues - Progress Community
 Bugs & Issues

Displayed Date

  • 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:1438
    Culture:ar-001; Year:2017
    Culture:ar-AE; Year:2017
    Culture:ar-BH; Year:2017
    Culture:ar-DJ; Year:2017
    Culture:ar-DZ; Year:2017
    Culture:ar-EG; Year:2017
    Culture:ar-ER; Year:2017
    Culture:ar-IL; Year:2017
    Culture:ar-IQ; Year:2017
    Culture:ar-JO; Year:2017
    Culture:ar-KM; Year:2017
    Culture:ar-KW; Year:2017
    Culture:ar-LB; Year:2017
    Culture:ar-LY; Year:2017
    Culture:ar-MA; Year:2017
    Culture:ar-MR; Year:2017
    Culture:ar-OM; Year:2017
    Culture:ar-PS; Year:2017
    Culture:ar-QA; Year:2017
    Culture:ar-SA; Year:1438
    Culture:ar-SD; Year:2017
    Culture:ar-SO; Year:2017
    Culture:ar-SS; Year:2017
    Culture:ar-SY; Year:2017
    Culture:ar-TD; Year:2017
    Culture:ar-TN; Year:2017
    Culture: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: