I have this string: 02/01/2019 13:00:00
I want get only the 02/01/2019
, so I did:
var date = DateTime.ParseExact(match.datetime.ToString(), \"dd/MM/
The problem is that in your format ("dd/MM/yyyy hh:mm:ss") you're specifying a 12-hour representation with "hh", but you're input is outside of that range: "13:00:00".
24 hour time is represented by HH
for parsing, not hh
.
Try something like this:
DateTime.ParseExact("02/01/2019 13:00:00", "dd/MM/yyyy HH:mm:ss", CultureInfo.InvariantCulture)