c# - Can't remove hidden characters from string -


i'm trying remove hidden characters string represents date time. i'm using .net fiddle , can see line tries parseexact fails.

here snippet. please refer fiddle link working code.

var datetime = "2015-04-14 07:30:00 pm"; //<= throws error hidden char     datetime = regex.replace(datetime, @"[^\w:\s-]", "");      console.writeline(datetime);     datetime datewithtime = datetime.parseexact(datetime, "yyyy-mm-dd hh:mm:ss tt",         cultureinfo.invariantculture);     console.writeline("ok"); 

the hh in format string refers 24-hour clock hours, doesn't work when using am/pm in format string pm times.

change hh hh.


Popular posts from this blog