DateTime picker C# format

c#, datetime, wpftoolkit

Solution

Something like this will display the date and time:

DateTimePicker1.Value.ToString("d-MMM-yyyy hh:mm:ss");

To override the default DateTimePicker settings, you can do this:

DateTimePicker1.Format = DateTimePickerFormat.Custom;
DateTimePicker1.CustomFormat = "d-MMM-yyyy  hh:mm:ss";

You can show a different time by modifying the format string, e.g.:

DateTimePicker1.CustomFormat = "d-MMM-yyyy 12:00:00";

or even

DateTime otherTime = DateTime.Now;
DateTimePicker1.CustomFormat = "d-MMM-yyyy " + otherTime.ToString("hh:mm:ss");

Problem

I have a `DateTime` picker to add arrival time to a list, I have 2 questions about it: - How can I get it to show dates like `12-Jan-2012` Instead of `12/01/12`? - How can I get it to show the time after the date but not the current time, as thats what is shows atm. My current code is not very advanced its just: ``` theVisit.ArrivalTime = DateTimePicker1.Value ```

Original source