//时间相减函数
procedure TimeMinus(StartTime,EndTime:string);
var
t,tmp:TDatetime;
d,h,n,s:integer;
str:string;
Begin
t:=abs(strtodatetime(EndTime)-strtodatetime(StartTime)); //"2019/01/02 03:04:05"
d:=trunc(t); //此前有用round,会出错
h:=trunc((t-d)*24);
tmp:=d+h/24;
n:=trunc((t-tmp)*1440);
tmp:=tmp+n/1440;
s:=trunc((t-tmp)*86400);
str:=inttostr(d)+'天'+inttostr(h)+'小时'+inttostr(n)+'分'+inttostr(s)+'秒';end;
联系客服