title: Getting time span between two times in C#?
body: <p>I have two textboxes. One for a clock in time and one for clock out. The times will be put in this format:</p>
  
  <pre><code>Hours:Minutes
  </code></pre>
  
  <p>Lets say I have clocked in at 7:00 AM and clocked out at 2:00 PM.</p>
  
  <p>With my current code, I get a difference of 2 hours, but it should be 7 hours. How would I do that in C#. I was going to convert to the 24 hour, by letting the user select AM or PM, but I got confused.</p>
  
  <p>So, basically, how would I calculate the difference of hours between the two times?</p>
  
  <p>I tried this, but got 2 hours and not 7 when I plugged in the numbers.</p>
  
  <pre><code>DateTime startTime = Convert.ToDateTime(textBox1.Text);
  DateTime endtime = Convert.ToDateTime(textBox2.Text);
  
  TimeSpan duration = startTime - endtime;
  </code></pre>