0

In my Windows Form application, I need to provide the end user to enter in a datetime of the format (MMDDYYYY HHMMSS)

I am using the DateTimePicker Control, however in the HHMMSS part - it takes in the current time of the day, by default --

var ArrivalDate = dtpArrivalDate.Value;

I need the flexibility for the user to enter a date like 10-11-2015 08:10:23

Can anyone suggest if there is any windows control, which allows the user to select HHMMSS from the front end, along with the date? Or else how can we append the HHMMSS part of the datetime entered by the user?

Sammy
  • 798
  • 2
  • 8
  • 23
  • possible duplicate of [DateTimePicker: pick both date and time](http://stackoverflow.com/questions/93472/datetimepicker-pick-both-date-and-time) – DeanOC Jun 29 '15 at 01:00
  • The HHMMSS shows the hours in 12hour clock. However I need to show it in 24hour clock. How can we achieve this? – Sammy Jun 29 '15 at 01:42

1 Answers1

0

Here's some code I refactored from another answer:

Update - change to 24h format

dtpArrivalDate.Format = DateTimePickerFormat.Custom;
dtpArrivalDate.CustomFormat = "MMddyyyy HHmmss";  

MSDN: DateTimePicker Class

MSDN: Custom DateTime Format Strings

DateTime ArrivalDate = dtpArrivalDate.Value;
Community
  • 1
  • 1
SimplyInk
  • 5,832
  • 1
  • 18
  • 27
  • Thanks. The HHMMSS shows the hours in 12hour clock. However I need to show it in 24hour clock. How can we achieve this? – Sammy Jun 29 '15 at 01:41
  • You can use [Custom DateTime Format Strings](https://msdn.microsoft.com/en-us/library/8kb3ddd4(v=vs.110).aspx) – SimplyInk Jun 29 '15 at 01:50