DateTime format in 'dd-mmm-yyyy'

2 posts, 0 answers
  1. sulagna
    sulagna avatar
    56 posts
    Member since:
    Sep 2010

    Posted 10 Jan 2011 Link to this post

    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.
  2. Kaloyan
    Kaloyan avatar
    920 posts

    Posted 12 Jan 2011 Link to this post

    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,
    the Telerik team
    Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
  3. DevCraft R3 2016 release webinar banner
Back to Top