Skip to content

DateToISO8601

Converts a TDateTime value to ISO 8601 date/time format

Declaration

Source position: dateutil.inc line 455

  function DateToISO8601(const ADate: TDateTime; AInputIsUTC: Boolean)
                         : string;

Description

DateToISO8601 is a String function used to convert the TDateTime value in ADate to ISO 8601 date/time notation.

ADate contains the native TDateTime value converted in the function.

AInputisUTC indicates if the value in ADate represents a date/time value for the UTC time zone. When AInputIsUTC contains True, the 'Z' (Zulu time) time zone designation is used in the converted ISO 8601 value. Otherwise, the time zone is expressed as a positive or negative number of hours and minutes (such as "-04:00") in the return value.

DateToISO8601 calls GetLocalTimeOffset to determine the time zone offset in use on the local computer. The integer offset is used to adjust the value in ADate to the UTC time zone when necessary.

The return value contains the adjusted value in ADate formatted using the notation:

yyyy-mm-ddThh:nn:ss.zzz±hh:nn or yyyy-mm-ddThh:nn:ss.zzzZ for Zulu time

Use ISO8601ToDate to convert the return value back to a native TDateTime type.

See also

Name Description
ISO8601ToDate Converts a date/time value in ISO 8601 notation to a native TDateTime type