Re: calculating difference of time in Delphi

Posted by William on November 04, 2005

In Reply to: calculating difference of time posted by robert on October 20, 2005:

: How can I calculate a difference of time?
: I have a program that begin at 12:00:10,200 and
: finish at 12:10:00,560 for example.
: I need to calculte the difference between two.

Declare two Delphi TDateTime variables, e.g. T1 for the starting time and T2 for the ending time. To measure and display the time span that a process takes:

T1 := Now;
Label1.Caption := FormatDateTime('"Start: " hh:nn:ss.zzz', T1);
// Process that you want to time:...
// ...
T2 := Now;
Label2.Caption := FormatDateTime('"Stop: " hh:nn:ss.zzz', T2);
Label3.Caption := FormatDateTime('"Diff: " hh:nn:ss.zzz', T2 - T1);

Related Articles and Replies


Delphi FAQ