Correct way to set Internationl date format

2 posts, 0 answers
  1. David Penny
    David Penny avatar
    174 posts
    Member since:
    Jun 2006

    Posted 06 Dec 2009 Link to this post

    Hi,

    I am using raddatetime pickers (Q3 2009) throughout my application and am stuggling a little to get the international date formats working correctly.

    I have added datetimepicker to a page and removed all culture information, and also tried culture="(Default)", but when I change culture in the browser dates always appear in UK English format (dd/mm/yyyy).

    I have tried adding the following code:

                Dim cultureInfo As CultureInfo = cultureInfo.CurrentCulture  
                dteLeaveStart.Culture = cultureInfo 

    But dates still appear in UK format.  If I change the line to cultureinfo.InvariantCulture then they do appear in mm/dd/yyyy format, but do this even if the culture is set to UK.

    I have also tried using a RadInputManager but cannot find how to set this programatically to use the culture information.

    I am assuming there must be some fairly simple method I am missing here and any guidance would be greatly appreciated.

    David Penny
  2. David Penny
    David Penny avatar
    174 posts
    Member since:
    Jun 2006

    Posted 06 Dec 2009 Link to this post

    Hi,

    I think I may have answered my own question, but would appreciate knowing if this is the best way of doing it.

    I have a datetimeinput defined as below:
    <telerik:RadDatePicker ID="dteLeaveStart" runat="server"   
                      SharedCalendarID="RadCalendar1" AutoPostBack="True" Culture="(Default)" DateFormat="d"   
                        DisplayDateFormat="d"  > 
                    <DateInput runat="server" AutoPostBack="True" > 
                    </DateInput> 
                    <Calendar runat="server">  
                    </Calendar> 
     
    <DatePopupButton ImageUrl="" HoverImageUrl=""></DatePopupButton> 
                </telerik:RadDatePicker> 

    I then have the following code in Page_Load:

    Dim cultureInfo As CultureInfo = cultureInfo.CurrentCulture  
    dteLeaveStart.Culture.DateTimeFormat.ShortDatePattern = cultureInfo.DateTimeFormat.ShortDatePattern  
    dteLeaveStart.Culture.DateTimeFormat.LongDatePattern = cultureInfo.DateTimeFormat.LongDatePattern  
    dteLeaveFinish.Culture.DateTimeFormat.ShortDatePattern = CultureInfo.DateTimeFormat.ShortDatePattern 

    This then seems to work OK. 

    Part of my problem was stupidity because I thought French dates were formatted mm/dd/yyyy and they do not appear to be.  This now works with UK. and US fate formats and so I assume it will do so with others as well.

    David Penny
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top