SmartPascal
ShortTimeFormat
Variable
Short version of the time to string format SysUtils unit
  var ShortTimeFormat : string;
Description
The ShortTimeFormat variable provides the short (compact) formatting used for certain time to string conversions.
 
It is used by the TimeToStr, DateTimeToStr and DateTimeToString routines (the latter when the 'c' or 't' formatting is used). The following formatting character strings can be used in the ShortTimeFormat 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
DateTimeToStr Converts TDateTime date and time values to a string
DateTimeToString Rich formatting of a TDateTime variable into a string
FormatDateTime Rich formatting of a TDateTime variable into a string
LongTimeFormat Long version of the time to string format
TimeToStr Converts a TDateTime time value to a string
 
Example code : Illustrating customised ShortTimeFormat 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 ShortTimeFormat 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 := StrToTime('15:06:23.456');

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

  // Change the display formatting
  ShortTimeFormat := 'hh nn ss';
  DateTimeToString(formattedDate, 't', myDate);
  ShowMessage('15:06:23.456 using override = '+formattedDate);
end;
 
end.
Hide full unit code
   15:06:23.456 using  default = 15:06
   15:06:23.456 using override = 15 06 23