DelphiBasics
TimeSeparator
Variable
The character used to separate display time fields SysUtils unit
  var TimeSeparator : char;
Description
The TimeSeparator variable is used in date and time display functions between hour, minute and second values.
 
TimeSeparator value is ':' by default, depending on the Windows locale.
Notes
DateSeparator = LOCALE_STIME by default.
Related commands
DateSeparator The character used to separate display date fields
DateTimeToString Rich formatting of a TDateTime variable into a string
StrToTime Converts a time string into a TDateTime value
TimeAMString Determines AM value in DateTimeToString procedure
TimePMString Determines PM value in DateTimeToString procedure
 Author links

 Download this web site as a Windows program.





 
Example code : Changing the time display separator character
// 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 TimeSeparator 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;

begin
  myDate := EndOfAMonth(2000, 2); // 29th Feb 2000 at 23:59:59.999

  LongTimeFormat := 'hh:mm:ss.zzz';   // Show milli-seconds

  ShowMessage('Date     = '+DateTimeToStr(myDate));
  TimeSeparator := '_';           // Override the : time separator
  ShowMessage('Date now = '+DateTimeToStr(myDate));
end;
 
end.
Hide full unit code
   Date     = 29/02/2000 23:59:59.999
   Date now = 29/02/2000 23_59_59.999
 
Delphi Programming Neil Moffatt 2002 - 2020. All rights reserved.  |  Home Page