Reputation: 51
I'm having problems with the next parse exact:
Time="4/1/2015 7:10:31 a m"
FechaLeida = DateTime.ParseExact(Time, "M/d/yyyy hh:mm:ss tt", new CultureInfo("en-US"));
I'm getting an exeption:
This string is not recognized as a Valid DateTime
Any ideas about what I'm doing wrong?
Upvotes: 2
Views: 76
Reputation: 5990
Your format and date is not macthing, you need to use 07
in hour because you mentioned hh
and also am has space as a m
var time="4/1/2015 07:10:31 am";
FechaLeida = DateTime.ParseExact(time, "M/d/yyyy hh:mm:ss tt", new CultureInfo("en-US"));
OR
var time="4/1/2015 7:10:31 am";
FechaLeida = DateTime.ParseExact(time, "M/d/yyyy h:mm:ss tt", new CultureInfo("en-US"));
Upvotes: 2