More in this section
Forums / Developing with Sitefinity / Arabic site News Listing to show date in Gregorian

Arabic site News Listing to show date in Gregorian

The forums are in read-only mode. In case that you want to directly contact the Progress Sitefinity team use the support center. In our Google Plus group you can find more than one thousand Sitefinity developers discussing different topics. For the Stack Overflow threads don’t forget to use the “Sitefinity” tag.
2 posts, 0 answered
  1. Paul
    Paul avatar
    14 posts
    Registered:
    10 Mar 2012
    31 Jul 2016
    Link to this post
    News listing plugin on Arabic site is showing publication date in Hijri format. I want it to be in Gregorian. Can anyone help?
  2. Victor Leontyev
    Victor Leontyev avatar
    65 posts
    Registered:
    01 Jul 2014
    13 Aug 2016 in reply to Paul
    Link to this post

    Hi Paul. I had the same problem. I just built new extension for ItemViewModel.

    public static class ItemViewModelExtension
        {
            public static string GetDateTimeGregorianCalendar(this ItemViewModel item, string fieldName, string format)
            {
                var date = (DateTime)item.Fields.GetMemberValue(fieldName);
                var culture = new CultureInfo(Thread.CurrentThread.CurrentUICulture.Name);
                GregorianCalendar calendar = new GregorianCalendar();
                culture.DateTimeFormat.Calendar = calendar;
                return date.ToString(format, culture);
            }
        }

    And in Feather widget template i am using 

    @item.GetDateTimeGregorianCalendar("PublicationDate", "MMM d, yyyy, HH:mm tt")

    instead 

    @item.GetDateTime("PublicationDate", "MMM d, yyyy, HH:mm tt")

     

2 posts, 0 answered