How to get the Time Difference in C# .net

Goldytech
Posted by Goldytech under C# category on | Views : 15207
 DateTime startTime, endTime;
startTime = Convert.ToDateTime("9:24 AM");
endTime = Convert.ToDateTime("10:24 AM");
var timeDiff = new TimeSpan(endTime.Ticks - startTime.Ticks);
MessageBox.Show("Time difference in hours is " + timeDiff.Hours);

Comments or Responses

Login to post response