大家好,我有个
 time1:tdatetime 类型 并且知道具体时间我如何写程序判断 当前时间和这个时间之间差大于 3.01 秒或3秒多一点,谢谢

解决方案 »

  1.   

    time1,timer2:tdatetime 
    time1 - time2   //返回两个时间差,如果这2个时间是到秒的,则以秒为单位,如果2个时间是到日的,则以日为单位。
      

  2.   

    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;
      

  3.   

    time1 如何获取当前时间,谢谢,到秒,只要时/分/秒  谢谢
      

  4.   

    uses dateUtil;//只有Delphi6带有这个库了里面就有计算两个dateTime类型的年差,月差,日差,时差,分差,秒差等几个函数,至于其它版本就有知道有没有了。还不明白,请给我留言,或QQ我吧。
      

  5.   

    我还是搞不懂,看看我写的程序
    time1,time2:string;  time1:=FormatDateTime('hh:nn:ss',Now);
    过几秒
      time2:=FormatDateTime('hh:nn:ss',Now);
      if (strtodatetime(time2)-strtodatetime(time1))>3 then showmessage('aa');不行啊,有别的办法吗,谢谢
      

  6.   

    if (StrToInt(FormatDateTime('ss',(t1 -t2))) = 1) then ShowMessage('ok') ;
      

  7.   

    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 秒
      

  8.   

    Uses DateUtils;//uses 加上这句begin
     time1:=Now;sleep(100);time2:=now;
     IF SecondsBetween(time1,time2)=3 then showmessage('aa');
    end;