im trying to parse exact a date based on the capture of information of a user from facebook. I get the error message: String was not recognized as a valid DateTime.
which is the best way to parse a date in the format dd/MM/yyyy
h.AddUser(r.id, r.FBid, accessToken, r.first_name, r.last_name, DateTime.ParseExact(r.birthday, "dd-MM-yyyy", System.Globalization.CultureInfo.InvariantCulture), r.email, DateTime.Now, r.gender, "http://graph.facebook.com/" + r.id + "/picture?type=large");
UPDATE:
if r.birthday is in dd/MM/yyyy then
DateTime.ParseExact(r.birthday, "dd/MM/yyyy", new System.Globalization.CultureInfo("en-GB"));
if r.birthday is in MM/dd/yyyy then
DateTime.ParseExact(r.birthday, "dd/MM/yyyy", new System.Globalization.CultureInfo("en-GB"));
i found a solution to my problem, posting it so if others are experiencing the same problem can find the same solution as me
So the string to be parsed is in dd/MM/yyyy format ?
Then specify that format to the parseExact method as such
DateTime.ParseExact(r.birthday, "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture)