Code:
int y = DateTime.Now.Year, m = DateTime.Now.Month, d = DateTime.Now.Day, s = 0; DateTime startTime = new DateTime(y, m, d, 5, 30, s); // 05:40 Hour DateTime endTime = new DateTime(y, m, d, 17, 45, s); // 17:45 Hour TimeSpan diff = endTime - startTime; int hourDiff = diff.Hours; // 12 Hours int minDiff = diff.Minutes; // 15 Mins double totDiffHours = (double)hourDiff + (double)minDiff / 60; // 12.25 Hours
No comments:
Post a Comment