delphi中时间的比较

qwe0828 2003-02-12 07:47:57
在delphi中用datatime类型的数据进行时间比较时我是这样处理的:
例如:var systime : datetime;
beforeopertime: datetime; --上次操作时间
begin
TimeOut := 6; -- 单位:秒
systime := now();
if systime - beforeopertime > (TimeOut/(24*60*60) then
--处理内容
end if;
end;
请问这样的处理方法是否正确?谢谢
...全文
110 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
oracle_lover 2003-02-12
  • 打赏
  • 举报
回复
你的写法好象没什么错。不过有另一种方法可能更好些:
var
beforeopertime:LongWord;
TimeOut:LongWord;
begin
TimeOut:=6000; //设置延迟为6秒
beforeopertime:=GetTickCount;
......

if GetTickCount>(beforeopertime+TimeOut) then
......
end;
qwe0828 2003-02-12
  • 打赏
  • 举报
回复
可以具体一点吗?
因为我现在这样的做法有时候会出错。
Devidzhang 2003-02-12
  • 打赏
  • 举报
回复
时间可以直接比较

5,931

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧