RadDatePicker DateFormat is not showing a 4 digit year

4 posts, 0 answers
  1. Parker
    Parker avatar
    7 posts
    Member since:
    Dec 2013

    Posted 22 Oct 2014 Link to this post

    I've try to set the DisplayFormat property to Short.  I've also tried to explicitly set the  format using StringFormat on the SelectedDate property.

    No matter what I do I can only get the mac to display a 2 digit year (the browser is Safari).  It works fine on windows.


    How can I make the selected date display in the format of MM/dd/yyyy?
  2. Parker
    Parker avatar
    7 posts
    Member since:
    Dec 2013

    Posted 22 Oct 2014 in reply to Parker Link to this post

    I'm not sure my first post was completely clear.  

    The issue that I'm having is with an Apple MacBook Air.  I've seen it on another Mac too.

    The Macs display the year in a 2 digit format and I can't get them to display a 4 digit year.
  3. DevCraft banner
  4. Georgi
    Admin
    Georgi avatar
    347 posts

    Posted 23 Oct 2014 Link to this post

    Hi Parker,

    Setting DisplayFormat  to short will mean that the DateTimePicker will use the sort format of the current culture on the machine (if not otherwise set). So on Mac the default culture is with only two digits and on Windows is with 4 and that is why the difference can be observed in the DateTimePicker.

    Nevertheless if you want to set the year to always 4 digits you can do so by setting the Culture property of the DateTimePicker:

    CultureInfo cultureInfo = new CultureInfo("en-us");
    DateTimeFormatInfo dateInfo = new DateTimeFormatInfo();
    dateInfo.ShortDatePattern = "MM/dd/yyyy";
    cultureInfo.DateTimeFormat = dateInfo;
     
    dateTimePicker.Culture = cultureInfo;

    Hope this would help.

    Regards,
    Georgi
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  5. Parker
    Parker avatar
    7 posts
    Member since:
    Dec 2013

    Posted 24 Oct 2014 in reply to Georgi Link to this post

    That worked, thanks.
Back to Top