title: 24Hour DateTime in C#
body: <p>I currently have the standard <code>Datetime</code> using <code>AM</code>/<code>PM</code>. I wish to have 24H Display. Searching the web gave me alot of options with <code>String.Format()</code> option. </p>
  
  <p>Problem is that this creates a string object to display the date. I need to use a <code>datetime</code> object because it is used in a table and the date column must be able to be sorted (asc/desc). The table is of a <code>GridView</code> Object.</p>
  
  <p><strong>Code Example</strong></p>
  
  <p>Currently the code shows the date as follows 8/21/2009 11:28:36 AM. I a perfect situation it would show as 11:28:36 21/8/2009. I know i can get that result with the following code.</p>
  
  <pre><code>date.ToString("dd/MM/yyyy HH:mm:ss");
  </code></pre>
  
  <p>Problem is that this is a string. The string get's placed into the table and if i sort the date column it will first sort on day instead of year. 
  showing the followin descending column.</p>
  
  <pre><code>21/8/2009 11:28:36
  20/1/2013 15:55:23
  </code></pre>
  
  <p>To correctly be able to sort the column the inserted objecttype should be DateTime. the object type is forced by the following code.</p>
  
  <pre><code>dateTable.Columns.Add(new DataColumn("Date", typeof(DateTime)));
  </code></pre>