title: Datetime in 24 hours Clock format in asp.net
body: <p>I have written this code for time calculation but my code is not accepting 24 hour time format. It is accepting only up to 12:59.</p>
  
  <p>This is my code:</p>
  
  <pre><code>protected void TxtId_TextChanged(object sender, EventArgs e)
  {
      GridViewRow currentRow = (GridViewRow)((TextBox)sender).Parent.Parent;
  
      TextBox txtTakenDate = (TextBox)currentRow.FindControl("txtTakenDate");
      TextBox txtTakenTime = (TextBox)currentRow.FindControl("txtTakenTime");
      TextBox txtReturnedDate = (TextBox)currentRow.FindControl("txtReturndDate");
      TextBox txtReturnedTime = (TextBox)currentRow.FindControl("txtReturndTime");
  
      TextBox txtmttr = (TextBox)currentRow.FindControl("txtmttr");
      string StartDate = txtTakenDate.Text;
      string StartTime = txtTakenTime.Text;
      DateTime StartDateTime = DateTime.ParseExact((StartDate + " " + StartTime), "dd/MM/yyyy hh:mm", CultureInfo.InvariantCulture);
  
      string EndDate = Convert.ToString(txtReturnedDate.Text);
      string EndTime = Convert.ToString(txtReturnedTime.Text);
      DateTime EndDateTime = DateTime.ParseExact((EndDate + " " + EndTime), "dd/MM/yyyy hh:mm", CultureInfo.InvariantCulture);
  
      TimeSpan TotalTime = EndDateTime.Subtract(StartDateTime);
      txtmttr.Text = string.Format("{0}:{1}", (int)TotalTime.TotalHours, TotalTime.Minutes);
  }
  </code></pre>