How to get the difference of two time and get MM:SS ofย time
Code Behind :
ย DateTime locCurrentDateTime = System.DateTime.Now;
TimeSpan difference = locCurrentDateTime.Subtract(Convert.ToDateTime(Session[“starttime”]));
double hrs = Math.Floor(difference.TotalMinutes);
double sec = difference.Seconds;
string time = new DateTime(difference.Ticks).ToString(“mm:ss”);
Note :
output for above code will be find total minutes between two time and formatted as MM:SS
Leave A Comment