将时间日期分解
procedure TForm1.Button1Click(Sender: TObject);
var
Present: TDateTime;
Year, Month, Day, Hour, Min, Sec, MSec: Word;
begin
Present:= Now;
SysUtils.DecodeDate(Present, Year, Month, Day);
Label1.Caption := 'Today is Day ' + IntToStr(Day) + ' of Month '
+ IntToStr(Month) + ' of Year ' + IntToStr(Year);
SysUtils.DecodeTime(Present, Hour, Min, Sec, MSec);
Label2.Caption := 'The time is Minute ' + IntToStr(Min) + ' of Hour '
+ IntToStr(Hour);
end;
时间差
procedure TForm1.Button1Click(Sender: TObject);
var
Year, Month, Day, Hour, Min, Sec, MSec: Word;
Hour1, Min1, Sec1, MSec1: Word;
begin
DecodeTime(now, Hour, Min, Sec, MSec);
DecodeTime(DateTimePicker1.Time,Hour1, Min1, Sec1, MSec1);
Edit1.Text:=inttostr((hour*3600 + min*60 + sec)-(hour1*3600 + min1*60 + sec1)) ;
end;
标签:Hour,Min,IntToStr,时间差,毫秒,TDateTime,Year,Month,Day From: https://www.cnblogs.com/sixty-five/p/17307469.html