How to calculate difference between two times?
asp.net, c#
Solution
Parse both of the textboxes values to `TimeSpan` and then you can take their difference using `-`.
TimeSpan ts1 = TimeSpan.Parse(textBox1.Text); //"1:35"
TimeSpan ts2 = TimeSpan.Parse(textBox2.Text); //"3:30"
label.Text = (ts2 - ts1).ToString(); //"1:55:00"
Problem
I have two textboxes that allow a user to enter a start time and an end time in this format (h:mm). I want it to return the difference in a label. For example, if a user enters 1:35 in the first textbox and 3:30 in the second textbox and press the 'Calculate' button, it will return the time 1:55. Any ideas or resources for this? I only want to calculate the hour and minute difference between two textboxes. Date and seconds doesn't matter at all.