[Back To Directory]

DateToStr(Date()); TimeToStr(Time());

1. Open Borland C++ Builder.
2. Place a Label on the form.
3. Place another Label on the form.
4. Place a Timer on the form.
5. Double click Timer1.
6. Type the following red code in the Timer1Timer function:

//This is what the Timer1Timer function should look like:

void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
   Label1->Caption = DateToStr(Date());
   Label2->Caption = TimeToStr(Time());
}
//---------------------------------------------------------------------------


7. Run the program, Label1 becomes the date and Label2 becomes the time.


Look up the DateToStr and TimeToStr functions in help to get more options on formating the date and time strings.





[Back To Directory]