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;
now 是现在的日期 date1 > date2 直接比就行了。
Indicates the relationship between the date portions of two TDateTime values.UnitDateUtilsCategorydatetime routinesDelphi syntax:function CompareDate(const A, B: TDateTime): TValueRelationship;C++ syntax:extern PACKAGE Types::TValueRelationship __fastcall CompareDate(const System::TDateTime A, const System::TDateTime B);DescriptionCall CompareDate to compare the two TDateTime values specified by A and B. CompareDate returns LessThanValue if A occurs on a day prior to the day specified by B. EqualsValue if A occurs on the same day as B, ignoring the time of day. GreaterThanValue if A occurs on a day that follows the day specified by B.//============================== Returns the day of the month represented by a TDateTime value.UnitDateUtilsCategorydatetime routinesDelphi syntax:function DayOf(const AValue: TDateTime): Word; MonthOf(const AValue: TDateTime): Word; YearOf(const AValue: TDateTime): Word;C++ syntax:extern PACKAGE Word __fastcall DayOf(const System::TDateTime AValue);DescriptionCall DayOf to obtain the day of the month represented by a specified TDateTime value. DayOf returns a value between 1 and 31.Note: DayOf returns the same value as the DayOfTheMonth function.
Label1.Caption := 'Today is Day ' + FormatDatetime('dd of Month mm of Year yyyy', now); Label2.Caption := 'The time is Minute ' + FormatDatetime('mm:ss of Hour hh', now);
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;
是现在的日期
date1 > date2
直接比就行了。
const System::TDateTime B);DescriptionCall CompareDate to compare the two TDateTime values specified by A and B. CompareDate returns LessThanValue if A occurs on a day prior to the day specified by B.
EqualsValue if A occurs on the same day as B, ignoring the time of day.
GreaterThanValue if A occurs on a day that follows the day specified by B.//==============================
Returns the day of the month represented by a TDateTime value.UnitDateUtilsCategorydatetime routinesDelphi syntax:function DayOf(const AValue: TDateTime): Word;
MonthOf(const AValue: TDateTime): Word;
YearOf(const AValue: TDateTime): Word;C++ syntax:extern PACKAGE Word __fastcall DayOf(const System::TDateTime AValue);DescriptionCall DayOf to obtain the day of the month represented by a specified TDateTime value. DayOf returns a value between 1 and 31.Note: DayOf returns the same value as the DayOfTheMonth function.
Label2.Caption := 'The time is Minute ' + FormatDatetime('mm:ss of Hour hh', now);