09.10.2014 Views

download pascal tutorial (pdf - Tutorials Point

download pascal tutorial (pdf - Tutorials Point

download pascal tutorial (pdf - Tutorials Point

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CHAPTER<br />

24<br />

Date Time<br />

This section shows various date and time functions:<br />

Most of the softwares you write need implementing some form of date functions<br />

returning current date and time. Dates are so much part of everyday life that it becomes<br />

easy to work with them without thinking. Pascal also provides powerful tools for date<br />

arithmetic that makes manipulating dates easy. However, the actual name and workings<br />

of these functions are different for different compilers.<br />

Getting the Current Date & Time:<br />

Pascal's TimeToString function gives you the current time in a colon(: ) delimited form.<br />

The following example shows how to get the current time:<br />

program TimeDemo;<br />

uses sysutils;<br />

begin<br />

writeln ('Current time : ',TimeToStr(Time));<br />

end.<br />

When the above code was compiled and executed, it produced the following result:<br />

Current time : 18:33:08<br />

The Date function returns the current date in TDateTime format. The TDateTime is a<br />

double value, which needs some decoding and formatting. The following program<br />

demonstrates how to use it in your program to display the current date:<br />

TUTORIALS POINT<br />

Simply Easy Learning Page 135

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!