How to convert string date to exact datetime?

Viewed 43

So basically im trying to convert the string date = "8/19/2022 7:07:29 AM" into datetime , ive tried all c# methods for converting the string into datetime but each time "string was not recognized as valid datetime" error is being thrown . How do i convert the said string into exact datetime in c# ?

Example i have tried :

DateTime.Parse(date);
Convert.ToDateTime(date);
DateTime.ParseExact(Date, "dd/MM/yyyy hh:mm:ss", CultureInfo.InvariantCulture);

for each of this method the same exception is being thrown

0 Answers
Related