Hello. I have a DateTime in this format "MM-dd-yyyy HH:mm:ss". What I need is to make it like this "yyyy-MM-dd HH:mm:ss". According to manual I'm trying first to make my datetime to string and then, using ParseExact method, convert it back to DateTime. So it looks like:
Code:
DateTime dt = another_datetime_that_was_assigned_before;
string format = "yyyy-MM-dd HH:mm:ss";
string dt_string = dt.ToString(format);
DateTime converted_dt = DateTime.ParseExact(dt_string, format, null); // there could be a CultureInfo instead of "null" but I can't figure out how it affects and if I need it at all
As a result I get:
dt_string = "2006-11-04 15:00:00" // That's actually what I need
converted_dt = "04-11-2006 15:00:00" // Like my "another_datetime_ ... "
I've also tried to use any cultures instead of null (like "en-US", "ru-RU") but failed. Now I'm completely lost and can't get where my mistake is. Thanks for your help.