This is a migrated thread and some comments may be shown as answers.

Correct way to set Internationl date format

1 Answer 110 Views
Input
This is a migrated thread and some comments may be shown as answers.
David Penny
Top achievements
Rank 2
David Penny asked on 06 Dec 2009, 11:16 AM
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

1 Answer, 1 is accepted

Sort by
0
David Penny
Top achievements
Rank 2
answered on 06 Dec 2009, 11:58 AM
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
Tags
Input
Asked by
David Penny
Top achievements
Rank 2
Answers by
David Penny
Top achievements
Rank 2
Share this question
or