How to convert string MM/dd/yyyy HH:ss
to DateTime
without changing the format. I just need to change the datatype from string
to DateTime
that's it. I have tried various ways but it doesn't give me my expected output.
String Input : 01/28/2018 20:00
Expected DateTime output : 01/28/2018 20:00
(only datatype should change)
Below are the some methods that I have tried:
DateTime.ParseExact("01/28/2018 20:00","MM/dd/yyyy HH:ss", CultureInfo.InvariantCulture)
: gives me2018-01-28T20:00:00
Convert.DateTime("01/28/2018 20:00")
gives me "String was not recognized as a valid DateTime" exceptionDateTime.Parse("01/28/2018 20:00")
this also gives me the same exception
Any help much appreciated.