Posted by webmaster Guido on January 14, 2003
In Reply to: Dates posted by Ste D on January 07, 2003
Delphi's TDateTimePicker is a wrapper around a Microsoft control. It allows you to show the date in one of two formats (long and short), but in Delphi 5 and lower it did not allow you to change the date nor the time format. That's because it uses the Windows date and time settings, not Delphi's internal format variables like "ShortDateFormat". In D6 and later, you can use the Format property to change the display of date or time. In D5 and earlier, use the DateTime_SetFormat call, as shown below. You'll have to add "CommCtrl" to the "USES" directive in the beginning of the unit, otherwise DateTime_SetFormat won't be recognized: uses Windows, Messages, ..., COMMCTRL; Next, put this in the FormCreate event handler: DateTime_SetFormat(DateTimePicker1.Handle, PChar('MM/dd/yyyy')); (attention: the 'MM' is in uppercase, 'mm' does not work)
|
|