计算流逝时间!(50分)

  • 主题发起人 主题发起人 yujiu2000
  • 开始时间 开始时间
Y

yujiu2000

Unregistered / Unconfirmed
GUEST, unregistred user!
假设有两个时间:dtp2.DateTime,dtp1.DateTime,
相差 dd:=dtp2.DateTime -dtp1.DateTime ;
得到相应的(*时*分*秒)

 
DecodeTime(dd,Hours,Minutes,Seconds,Milliseconds)
 
自己作個函數吧,
用分割decodetime函數把兩個時間的時,分,秒,分割出來,
再相減,
 
如果你使用的是Delphi7,在DateUtils单元中有如下函数可以容易的得到你需要的结果:
function HoursBetween(const ANow, AThen: TDateTime): Int64;
function MinutesBetween(const ANow, AThen: TDateTime): Int64;
function SecondsBetween(const ANow, AThen: TDateTime): Int64;
 
如樓上所說的就可以了。
DELPHI自帶了分解的函數的。不但能分解時分秒,還能分解出年月日。
Returns Year, Month, Day, Hour, Minute, Second, and Millisecond values for a TDateTime.

Unit

DateUtils

Category

datetime routines

Delphi syntax:

procedure DecodeDateTime(const AValue: TDateTime; out AYear, AMonth, ADay, AHour, AMinute, ASecond, AMilliSecond: Word);
 
在delphi中自带了一个DateUtils单元,里面有各种计算时间的函数。
 
后退
顶部