DateTime (C++)
Description
This example uses a label and a button on a form. When you click the button, the current date displays in the caption of the label. Because some of the date variables are assigned new values, the format of the date in the label changes. For example, if the date is 9/15/94, the date displays as 9-15-1994.
Code
void __fastcall TForm1::Button1Click(TObject *Sender)
{
DateSeparator = '-';
ShortDateFormat = "m/d/yyyy";
Label1->Caption = DateToStr(Date());
}
Uses
- System.SysUtils.TFormatSettings.CurrencyFormat ( fr | de | ja )
- System.SysUtils.TFormatSettings.DateSeparator ( fr | de | ja )
- System.SysUtils.TFormatSettings.ShortDateFormat ( fr | de | ja )
- System.SysUtils.DateToStr ( fr | de | ja )