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

DateTime format in 'dd-mmm-yyyy'

1 Answer 223 Views
DateTimePicker
This is a migrated thread and some comments may be shown as answers.
sulagna
Top achievements
Rank 1
sulagna asked on 10 Jan 2011, 01:49 PM
Hi,
I am using RadDateTimePicker which is displaying the date value as dd/mm/yyyy by default.I want to change it to dd-mmm-yyyy.
For eg. the pic that I have attached its displaying the Start Date ( red circled ) as 3/15/2010 i.e. dd/mm/yyy format but it should display like 15-Mar-2010  i.e dd-mmm-yyyy.

My xaml is given below where I am getting the value of ProjectStartDate as 15-Mar-2010 format in view model and binding that but while displaying its taking 3/15/2010 format.I also tried with DateConverter class but of no use.
<telerik:RadDateTimePicker x:Name="datePicker" Width="100" Height="25" SelectedDate="{Binding ProjectStartDate,Mode=TwoWay}" InputMode="DatePicker" IsEnabled="{Binding EnaDisStartDate}" Grid.Column="5" Grid.Row="0"/>

In view  model ProjectStartDate is a public property and I am changing to the dd-mmm-yyy pattern by using below code and ProjectStartDate I bind in xaml but its displaying in dd/mm/yyyy format.
ProjectStartDate = project.StartDate.Date.ToString("dd-MMM-yyyy");
public String ProjectStartDate { get; set; }

Please help.
Sulagna

1 Answer, 1 is accepted

Sort by
0
Kaloyan
Telerik team
answered on 12 Jan 2011, 11:03 AM
Hi sulagna,

You can set the date format by changing the culture property. Follow the code bellow:

radDateTimePicker.Culture = new CultureInfo("en-US")
        {
            DateTimeFormat = new DateTimeFormatInfo
            {
                ShortDatePattern = "dd-MMM-yyyy"
            }
        };

All the best,
Kaloyan
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
Tags
DateTimePicker
Asked by
sulagna
Top achievements
Rank 1
Answers by
Kaloyan
Telerik team
Share this question
or