Description |
The LongDateFormat variable provides the long (extended) formatting used for certain date to string conversions.
It is used by the DateTimeToString routine when the 'dddddd' formatting is used.
The following formatting character strings can be used in the LongDateFormat string:
y | = Year last 2 digits |
yy | = Year last 2 digits |
yyyy | = Year as 4 digits |
m | = Month number no-leading 0 |
mm | = Month number as 2 digits |
mmm | = Month using ShortDayNames (Jan) |
mmmm | = Month using LongDayNames (January) |
d | = Day number no-leading 0 |
dd | = Day number as 2 digits |
ddd | = Day using ShortDayNames (Sun) |
dddd | = Day using LongDayNames (Sunday) |
|
|
Notes |
The default value is set from LOCALE_SLONGDATE
|
|
Related commands |
|
|
|
Example code : Illustrating customised LongDateFormat setting |
// Full Unit code. // ----------------------------------------------------------- // You must store this code in a unit called Unit1 with a form // called Form1 that has an OnCreate event called FormCreate. unit Unit1; interface uses SysUtils, // Unit containing the LongDateFormat command DateUtils, Forms, Dialogs; type TForm1 = class(TForm) procedure FormCreate(Sender: TObject); end; var Form1: TForm1; implementation {$R *.dfm} // Include form definitions procedure TForm1.FormCreate(Sender: TObject); var
myDate : TDateTime;
formattedDate : string;
begin
myDate := StrToDate('29/02/2000');
// Display using the default LongDateFormat
DateTimeToString(formattedDate, 'dddddd', myDate);
ShowMessage('29/02/2000 using default = '+formattedDate);
// Change the display formatting
LongDateFormat := 'dddd dd of mmmm yyyy';
DateTimeToString(formattedDate, 'dddddd', myDate);
ShowMessage('29/02/2000 using override = '+formattedDate);
end; end.
|
Hide full unit code |
29/02/2000 using default = 29 February 2000
29/02/2000 using override = Tuesday 29 of February 2000
|
|