procedure TForm1.Button1Click(Sender: TObject);var Present: TDateTime; Year, Month, Day, Hour, Min, Sec, MSec: Word; begin Present:= Now; DecodeDate(Present, Year, Month, Day); Label1.Caption := 'Today is Day ' + IntToStr(Day) + ' of Month ' + IntToStr(Month) + ' of Year ' + IntToStr(Year); DecodeTime(Present, Hour, Min, Sec, MSec); Label2.Caption := 'The time is Minute ' + IntToStr(Min) + ' of Hour ' + IntToStr(Hour); end;
Uses dateUtils HourOf(Time) MinuteOf(Time)
Uses dateUtils HourOf(Time) MinuteOf(Time)
用decodedata 和decodetime 两个函数啊
decodedata Returns Year, Month, and Day values for a TDateTime value.UnitSysUtilsCategorydatetime routinesDelphi syntax:procedure DecodeDate(Date: TDateTime; var Year, Month, Day: Word); DescriptionThe DecodeDate procedure breaks the value specified as the Date parameter into Year, Month, and Day values. If the given TDateTime value has a negative (BC) year, the year, month, and day return parameters are all set to zero.
Present: TDateTime;
Year, Month, Day, Hour, Min, Sec, MSec: Word;
begin
Present:= Now;
DecodeDate(Present, Year, Month, Day);
Label1.Caption := 'Today is Day ' + IntToStr(Day) + ' of Month '
+ IntToStr(Month) + ' of Year ' + IntToStr(Year);
DecodeTime(Present, Hour, Min, Sec, MSec);
Label2.Caption := 'The time is Minute ' + IntToStr(Min) + ' of Hour '
+ IntToStr(Hour);
end;
HourOf(Time)
MinuteOf(Time)
HourOf(Time)
MinuteOf(Time)
和decodetime 两个函数啊
Returns Year, Month, and Day values for a TDateTime value.UnitSysUtilsCategorydatetime routinesDelphi syntax:procedure DecodeDate(Date: TDateTime; var Year, Month, Day: Word);
DescriptionThe DecodeDate procedure breaks the value specified as the Date parameter into Year, Month, and Day values. If the given TDateTime value has a negative (BC) year, the year, month, and day return parameters are all set to zero.
小时:Hour:Word;
分:Min:Word;
秒:Sec:Word;
毫秒:MSec:Word;
DecodeTime(DateTime, Hour, Min, Sec, MSec);
(初学者,难免有错误,错了别怪我喔!)