Mirror

Converting a integer containing millisecs to a nice formated string (Views: 102)


Problem/Question/Abstract:

Converting a integer containing millisecs to a nice formated string.

Answer:

This routine formats an integer representing milliseconds into a nice formated string:  HH:MM:SS:Ms.
I use it in an audio application.

function MSecToStr(MSec: Integer): string;
begin
  Result := FormatFloat('00', MSec mod 1000 div 10); // msec
  MSec := MSec div 1000;
  Result := FormatFloat('00', MSec mod 60) + ':' + Result; // sec
  MSec := MSec div 60;
  Result := FormatFloat('00', MSec mod 60) + ':' + Result; // min
  MSec := MSec div 60;
  Result := IntToStr(MSec mod 60) + ':' + Result; // hour
end;

<< Back to main page