DelphiBasics
LongTimeFormat
Variable
Long version of the time to string format SysUtils unit
var LongTimeFormat : string;
Description
The LongTimeFormat variable provides the long (extended) formatting used for certain time to string conversions.
 
It is used by the DateTimeToString routine when the 'tt' formatting is used. The following formatting character strings can be used in the LongTimeFormat string:
 
= Hour with no leading 0's
hh  = Hour as 2 digits
= Minute with no leading 0's
nn  = Minute as 2 digits
= Seconds with no leading 0's
ss  = Seconds as 2 digits
= Milli-seconds with no leading 0's
zzz  = Milli-seconds as 3 digits
Notes
The default value is calculated from LOCALE_ITIME and LOCALE_ITLZERO
Related commands
DateTimeToStrConverts TDateTime date and time values to a string
DateTimeToStringRich formatting of a TDateTime variable into a string
FormatDateTimeRich formatting of a TDateTime variable into a string
ShortTimeFormatShort version of the time to string format
TimeToStrConverts a TDateTime time value to a string
 Download this web site as a Windows program.




 
Example code : Illustrating customised LongTimeFormat setting
var
  myDate : TDateTime;
  formattedDate : string;

begin
  myDate := StrToTime('15:06:23.456');

  // Display using the default LongTimeFormat
  DateTimeToString(formattedDate, 'tt', myDate);
  ShowMessage('15:06:23.456 using  default = '+formattedDate);

  // Change the display formatting
  LongTimeFormat := 'hh nn ss (zzz)';
  DateTimeToString(formattedDate, 'tt', myDate);
  ShowMessage('15:06:23.456 using override = '+formattedDate);
end;
Show full unit code
  15:06:23.456 using default = 15:06:23
  15:06:23.456 using override = 15 06 23 (456)
 
Delphi Programming © Neil Moffatt . All rights reserved.  |  Home Page