var datetime1,datetime2:Tdatetime; year1,month1,day1,hour1,min1,sec1,msec1:word; year2,month2,day2,hour2,min2,sec2,msec2:word; begin decodedate(datetime1,year1,month1,day1); decodedate(datetime2,year2,month2,day2); decodetime(datetime1,hour1,min1,sec1,msec1); decodetime(datetime2,hour2,min2,sec2,msec2);end;
我还是搞不懂,看看我写的程序 time1,time2:string; time1:=FormatDateTime('hh:nn:ss',Now); 过几秒 time2:=FormatDateTime('hh:nn:ss',Now); if (strtodatetime(time2)-strtodatetime(time1))>3 then showmessage('aa');不行啊,有别的办法吗,谢谢
if (StrToInt(FormatDateTime('ss',(t1 -t2))) = 1) then ShowMessage('ok') ;
time1,time2:string; time1:=FormatDateTime('hh:nn:ss',Now); 过几秒 time2:=FormatDateTime('hh:nn:ss',Now); if (StrToInt(FormatDateTime('ss',(time1 -time2))) = 3) then showmessage('aa'); //3 秒
Uses DateUtils;//uses 加上这句begin time1:=Now;sleep(100);time2:=now; IF SecondsBetween(time1,time2)=3 then showmessage('aa'); end;
time1 - time2 //返回两个时间差,如果这2个时间是到秒的,则以秒为单位,如果2个时间是到日的,则以日为单位。
datetime1,datetime2:Tdatetime;
year1,month1,day1,hour1,min1,sec1,msec1:word;
year2,month2,day2,hour2,min2,sec2,msec2:word;
begin
decodedate(datetime1,year1,month1,day1);
decodedate(datetime2,year2,month2,day2);
decodetime(datetime1,hour1,min1,sec1,msec1);
decodetime(datetime2,hour2,min2,sec2,msec2);end;
time1,time2:string; time1:=FormatDateTime('hh:nn:ss',Now);
过几秒
time2:=FormatDateTime('hh:nn:ss',Now);
if (strtodatetime(time2)-strtodatetime(time1))>3 then showmessage('aa');不行啊,有别的办法吗,谢谢
过几秒
time2:=FormatDateTime('hh:nn:ss',Now);
if (StrToInt(FormatDateTime('ss',(time1 -time2))) = 3) then showmessage('aa'); //3 秒
time1:=Now;sleep(100);time2:=now;
IF SecondsBetween(time1,time2)=3 then showmessage('aa');
end;