This blog talks about RadDatePicker especially its behaviour, DisplayDateFormat format and relation with ASP.NET culture settings.
There is always confusion around this two properties in multi-lingual ASP.NET application. Consider a case where IIS Server Time Zone is set to US EST and client is in UK using this application. The system is built to display date in US date format and user is entering date in UK date format. So after entering date, month and date does not display as expected. User trying to enter 01/12/2014 will display as 1/12/2014 which is Jan 12, 2014. User wanted 1st Dec 2014.
Let us get into more details by looking at code and example. The ASP.NET application is designed to display date in specific format and it is set to ‘M/d/yyyy’ to RadDateInput.DisplayDateFormat throughout the application for each RadDatePicker. This means 1st December 2014 will display as 12/01/2014 everywhere in system. User from UK is using this system so the DateInput.Culture is automatically set to en-US which has date format ‘M/d/yyyy’. This can be simulated by setting properties as show in code below
<telerik:RadDatePicker DateInput-DisplayDateFormat="M/d/yyyy" DateInput-Culture="en-US" ID="RadDatePicker1" runat="server"></telerik:RadDatePicker>
Now, entering 01/12/2014 will be interpreted as Jan 12, 2014. You may confirm by clicking on Calendar icon.
So what is best way? Culture property plays import part here. Date enter by user will be broken into 3 parts. Date, Month and Year. This will be taken as input to generate actual date value. In above case Culture is set to en-US and so the date format is ‘M/d/yyyy’. The inputs are January as month, 01 as Date and 2014 as year. This will be arranged as 1/12/2014 instead of 01 December 2014.
To work in synch with end user culture, set culture based on user locale. So in this case, user using system from UK should have Culture = en-GB. This way date will interpreted way user inputs. Display format can be anything, once date parts (day, month, year) are captured correct, it can be display in any format.