I have multiple input in string like the following:-
- 05/09/2017
- 05/09/2017 13:56 PM
- 05/09/2017 01:56 PM
- 05/09/2017 13:56:00
- 05/09/2017 01:56:00 PM
Now how do i convert the above examples into DateTime format (dd/MM/yyyy hh:mm:ss tt).
I have already tried
ParseExact - It gives error when the user gives 05/09/2017 as value (because the format doesn't match)
DateTime.ParseExact(ValueByuser, "dd/MM/yyyy HH:mm:ss tt", null);
TryParse - The problem with it is that it uses the LocalFormat of the computer like if the computer has set to "MM/dd/yyyy" then it produces output in the same format
DateTime.TryParse(DatePass, out Dtp);