Convert Time into Elapsed Time

How do you convert an actual time into elapsed Time

I.e. this

22:30:08
22:30:28
22:30:48
22:31:08

into this
0.08
0.28
0.48
1.08



LVL 2
phunchakAsked:
Who is Participating?
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
So 22:30:00 is the start time?

Use two DateTime() instances and then use their Subtract() method to get a TimeSpan() instance which is what you want.

Something like...

    DateTime startDT = DateTime.Now;

    // do some stuff...

    DateTime stopDT = DateTime.Now;

    TimeSpan ts = stopDt.Subtract(startDt);
    MessageBox.Show(ts.TotalMinutes.ToString());
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.