Home  |  Delphi .net Home  |  System.TimeSpan  |  ToString Method
  
ToString  
Method  
Converts a TimeSpan value into a string
TimeSpan Structure
System NameSpace
CF1.  Function ToString : String;
CF : Methods with this mark are Compact Framework Compatible
Description
The ToString method is the converse of the Parse method. (The output of one can be used safely as the input to the other).
 
The format of the output string is as follows :
 
[-][days.]hours:mins:secs[.frac]
 
Where
 
The sign is only shown if the value is negative
days Only appears if non-zero
hours Always shown, followed by ':'
mins Always shown, followed by ':'
secs Always shown
frac Only appears if non-zero milliseconds
Microsoft MSDN Links
System
System.TimeSpan
 Author links

 Buy Website Traffic at
 Buywebsitetrafficexperts.com

 Buy Proxies at
 Buyproxies.io
 
 
 
A simple example
program Project1;
{$APPTYPE CONSOLE}

var
  span1, span2, span3 : TimeSpan;

begin
  span1 := System.TimeSpan.Create( 8, 30, 0);          //  8 hours 30 mins
  span2 := System.TimeSpan.Create(17,  0, 0, 0);       // 17 days
  span3 := System.TimeSpan.Create( 0,  0, 0, 0, 1234); // 1234 millis

  Console.WriteLine('span1 = {0}', span1.ToString);
  Console.WriteLine('span2 = {0}', span2.ToString);
  Console.WriteLine('span3 = {0}', span3.ToString);

  Console.ReadLine;
end.
   span1 = 08:30:00
   span2 = 17.00:00:00
   span3 = 00:00:01.2340000
 
 
Delphi Programming Neil Moffatt 2002 - 2017. All rights reserved.  |  Contact the author