DecodeDate (C++)

From RAD Studio Code Examples
Jump to: navigation, search

Description

This example uses a button and two labels on a form. When you click the button, the current date and time are reported in the captions of the two labels.

Code

void __fastcall TForm1::Button1Click(TObject *Sender)
{
  Word Year, Month, Day, Hour, Min, Sec, MSec;
  TDateTime dtPresent = Now();
  DecodeDate(dtPresent, Year, Month, Day);
  Label1->Caption = String("Today is Day ") + IntToStr(Day) + String(" of Month ") + IntToStr(Month) + String(" of Year ") + IntToStr(Year);
  DecodeTime(dtPresent, Hour, Min, Sec, MSec);
  Label2->Caption = String("The time is Minute ") + IntToStr(Min) + String(" of Hour ") + IntToStr(Hour);
}

Uses