How can I convert this 7/3/2015 12:40:02 PM
to DateTime with format \"dd/MM/yyyy hh:mm:ss tt\"
I have done like this:
BreackEndTime
This is the code that worked well in my case:
Console.WriteLine("deal with regex datetime: ");
string input = "11/24 5:41:00 AM";
DateTime newDate;
CultureInfo enUS = new CultureInfo("en-US");
try
{
newDate = DateTime.ParseExact(input, "M/d h:mm:ss tt", CultureInfo.InvariantCulture);
Console.WriteLine("parse result: " + newDate);
}
catch (Exception err)
{
Console.WriteLine("error parsing input string. date format is wrong or string chaged " + err);
}