Delphi 获取时间的年月日

时间:2022-12-02 12:21:25

procedure TFrmLltj.FormActivate(Sender: TObject);

var
   Present: TDateTime;
   Year, Month, Day, Hour, Min, Sec, MSec:Word;
begin
   Present:= Now;
   DecodeDate(Present, Year, Month, Day);
   DecodeTime(Present, Hour, Min, Sec, MSec);
   Showmessage(DateToStr(Present)+' '+TimeToStr(Present,'hh'));//显示年月日时分秒
   Showmessage(formatdatetime('hh:mm',time));//显示时分
   cbb_qs_n.Text := inttostr(Year);//显示年
   cbb_qs_y.Text := inttostr(Month);//显示月
   cbb_qs_r.Text := inttostr(Day);//显示日
   cbb_qs_s.Text := IntToStr(Hour);//显示时
   cbb_qs_f.Text := IntToStr(Min);//显示分

end;