title: How to convert datetime dynamically based on culture in c#
body: <p>I have created WPF application in C#. In this application I have created one report which is get date from user. For get date , I am using C# datetime control. My datetime control display value as per computer culture. for e.g in my machine when i am selecting date from control, it's display "27-1-2017 12.00.00 AM" when i am test my application in other machine it's display 27/1/2017 12.00.00 AM</p>
  
  <p>So my issue is that I am getting error <strong>"String was not recognized as a valid DateTime."</strong> when convert Datetime.</p>
  
  <p>I have tried <strong>DateTime.ParseExact,DateTime.Parse</strong> but still I am not able to succeeded to fix my problem.</p>
  
  <pre><code> DateTime l_dtFrom = Convert.ToDateTime("27-1-2017 12.00.00 AM", CultureInfo.CurrentCulture);
   string l_sFromDate = l_dtFrom.ToString("yyyy-MM-dd HH:mm:ss");
  </code></pre>