title: DateTime.Compare method is not working with different languages
body: <p>I need to compare two <code>DateTime</code> values in my DotNetNuke module, like this:</p>
  
  <pre><code>// This value actually comes from the database.
  DateTime time1 = Convert.ToDateTime("6/2/2013 5:21:05 PM");
  
  // Say it is now "5/31/2013 2:20:33 AM"
  DateTime now = DateTime.Now;
  
  int num = DateTime.Compare(time1, now);
  </code></pre>
  
  <p>As you can see, <code>num == 1</code> because the <code>DateTime</code> value of <code>time1</code> is greater than the <code>DateTime</code> value of <code>now</code>.  But when I change the language to German (<code>de-DE</code>) in the DotNetNuke settings, the value of <code>now</code> becomes - <code>31/5/2013 2:20:33 AM</code>.  The result is that <code>num</code> becomes <code>-1</code>, meaning <code>time1</code> is <em>earlier</em> than <code>now</code>.  This is incorrect because <code>time1</code> is actually later than <code>now</code>.</p>
  
  <p>The <code>time1</code> value is always in <code>mm/dd/yyyy</code> format because it is coming from the server.</p>
  
  <p>So, how do I get the right comparison in case another language is set in DotNetNuke?  When I searched the web, I found that I can correct the time with the following code: </p>
  
  <pre><code>provider = new CultureInfo("en-US");
  DateTime.ParseExact("5/31/2013", "d", provider);
  </code></pre>
  
  <p>Is that correct?  Is there a better way to handle this concern?</p>
  
  <p>Edited</p>
  
  <p>forgot to say that time 1 comes from my website server before saving to db and is compared with client's  website's datetime value in  now variable.all codes is my app which is in that client site.these codes at first accessed  time1 date by .net methods of getting remote site data.so when that dnn site language is set as de-DE  look 'now' variable value is day first which is reverse from my site date is US format month first.in consequence when comparison takes place, my server date is resulted as earlier than client site date! And everything breaks.FYI my server date came as a i week later date which is 2nd june for license purpose.   </p>
  
  <p>Edited again:</p>
  
  <p>Hi every1.I found a solution by the following codes.This date comes from my another server as i said above - "6/15/2013"(changing it was bef4 6/2/2013).It's in string format, why it's a string? it's a long history.just let it be a string right now.before converting to string it was in US date format(month before).Now in current website where my app is, these codes seem working.Hope i am not wrong, please confirm</p>
  
  <pre><code>CultureInfo provider = CultureInfo.InvariantCulture;
  provider = new CultureInfo("en-US");
  DateTime time1 = DateTime.ParseExact("6/15/2013", "d", provider);                    
  DateTime now = DateTime.Now;
  int num = DateTime.Compare(time1, now);
  </code></pre>
  
  <p>"num" returning 1 which is right whether dnn site language is German or English.</p>