title: Unity c# convert date-string to datetime object in desired date time format
body: <p>I need to convert a list of strings that contain date information (e.g. "2018-12-16") into DateTime format so that I can sort them all by date...and then convert back to string... I'm struggling to make this work. Testing on one of the strings:</p>
  
  <pre><code>string dateTimeString = "2018-12-16";
  System.DateTime dateTime = System.DateTime.Parse(dateTimeString);
  print(dateTime.ToString());
  </code></pre>
  
  <p>which prints <code>"12/15/2018 12:00:00 AM"</code> - but I don't want the time, and the format is different.. so I tried this (specifying the date format):</p>
  
  <pre><code>string dateTimeString = "2018-12-16";
  System.DateTime.ParseExact(dateTimeString, new string[] { "yyyy-MM-dd" }, new System.Globalization.CultureInfo("en-AU"), System.Globalization.DateTimeStyles.None);
  print(dateTime.ToString());
  </code></pre>
  
  <p>this has the same result.</p>
  
  <p>I've tried making the format conversion going the other way:</p>
  
  <pre><code>string dateTimeString = System.String.Format("{0:yyyy-MM}", dateTime);
  print(dateTimeString);
  </code></pre>
  
  <p>this also has the same result!</p>
  
  <p>Can someone please help me, or point me in the direction of some decent documentation / examples?
  Thanks!</p>