[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] Reference for unit 'sysutils' (#rtl)

DateTimeToStr

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

Declaration

Source position: datih.inc line 138

function DateTimeToStr(

  DateTime: TDateTime;

  ForceTimeIfZero: Boolean = False

):string;

function DateTimeToStr(

  DateTime: TDateTime;

  const FormatSettings: TFormatSettings;

  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.

Errors

None.

See also

FormatDateTime

  

Return a string representation of a TDateTime value with a given format.

DefaultFormatSettings

  

Storage for default settings

Example

Program Example3;

{ This program demonstrates the DateTimeToStr function }

Uses sysutils;

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

Documentation generated on: Jun 22 2020