TDateTime a = StrToDateTime(“2015-02-09 09:25:00”);
WORD hh,mm,ss,ms;
DecodeTime(Now()-a,hh,mm,ss,ms);
ShowMessage(hh*60*60+mm*60+ss);
这里只能求一天之内的时间差,要把天数考虑进去,参考下面函数:
DateUtils.YearsBetween();
DateUtils.MonthsBetween();
DateUtils.WeeksBetween();
DateUtils.DaysBetween();
DateUtils.HoursBetween();
DateUtils.MinutesBetween();
DateUtils.SecondsBetween();
DateUtils.MilliSecondsBetween();
DateUtils.YearSpan();
DateUtils.MonthSpan();
DateUtils.WeekSpan();
DateUtils.DaySpan();
DateUtils.HourSpan();
DateUtils.MinuteSpan();
DateUtils.SecondSpan();
DateUtils.MilliSecondSpan();