Sign in Join
FPDoc Onlineexperiment

DateTimeToStr function

In unit sysutils

Converts a TDateTime value to a string using a predefined format.

Declaration

pascal
function DateTimeToStr(DateTime: TDateTime; 
 ForceTimeIfZero: Boolean=False): string

Description

DateTimeToStr returns a string representation of DateTime using the formatting specified in ShortDateFormat and LongTimeFormat. It corresponds to a call to FormatDateTime('c',DateTime) (see formatchars).

Note that if the time part is 0 (i.e. midnight), no time is appended.

Note that on unix systems, the localization support must be enabled explicitly, see Localization.

Errors

None.

See also

Example: ex3

pascal
Program Example3;

{ This program demonstrates the DateTimeToStr function }

Uses sysutils;

Begin
  Writeln ('Today is : ',DateTimeToStr(Now));
  Writeln ('Today is : ',FormatDateTime('c',Now));
End.

An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.