I have two strings:
string one = \"13/02/09\";
string two = \"2:35:10 PM\";
I want to combine these two together and convert to a Dat
Convert.ToDateTime
uses DateTime.ParseExact
with your current thread's culture, so you can make things a bit clearer by simply doing:
string date = "13/02/09";
string time = "2:35:10 PM";
DateTime dateTime = DateTime.Parse(date +" "+ time, new CultureInfo("en-GB"));
Console.WriteLine (dateTime);
That gives the result 13/02/2009 14:35:10
, and forces the parse to use the en-GB date time formats. If your Windows installation is en-GB anyway, you don't need the CultureInfo(..)
argument.