[Overview][Constants][Procedures and functions][Index] | Reference for unit 'DateUtils' (#rtl)

# ISO8601ToDateDef

Converts an ISO 8601 date/time string to a TDateTime type

## Declaration

Source position: dateutil.inc line 470

`function ISO8601ToDateDef(`
`const DateString: string;`
`ReturnUTC: Boolean;`
`aDefault: TDateTime`
`):TDateTime; function ISO8601ToDateDef(`
`const DateString: string;`
`aDefault: TDateTime;`
`ReturnUTC: Boolean = True`
`):TDateTime;`

## Arguments

`DateString` |  | String containing the ISO 8601 date/time value converted in the function
`ReturnUTC` |  | Indicates if the TDateTime value should be adjusted to the UTC time zone
`aDefault` |  | Default TDateTime value used in the result

## Function result

TDateTime value for the specified ISO 8601 date/time

## Arguments

`DateString` |  | String containing the ISO 8601 date/time value converted in the function
`aDefault` |  | Default TDateTime value used in the result
`ReturnUTC` |  | Indicates if the TDateTime value should be adjusted to the UTC time zone

## Description

ISO8601ToDateDef is used to convert a date/time string in ISO 8601 format to its representation as a TDateTime value. DateString contains the ISO 8601-formatted date/time value converted in the routine. It can use one of the supported ISO 8601 date/time formats, and may contain an optional time zone offset. DateString uses the format returned from the DateToISO8601 function. Each of the following represent the date/time for Noon on July 4, 2019:

- 20190714 12:00
- 2019-07-14 12:00
- 20190714 12:00:00
- 2019-07-14 12:00:00
- 20190714T12:00
- 20190714T12:00:00
- 2019-07-14T12:00
- 2019-07-14T12:00:00
- 20190714T12:00:00-04:00
- 2019-07-14T12:00:00-04:00

Time values in DateString specified without a time zone offset are assumed to be in the local time zone.

ReturnUTC indicates if the value in DateString is adjusted to UTC (Coordinated Universal Time) in the return value.

aDefault contains the default TDateTime value used as the return value when DateString cannot be successfully parsed and converted.

Please note than that the overloaded variant which uses String, Boolean, and TDateTime arguments has been deprecated. Use the variant with String, TDateTime, and Boolean arguments (in that order) instead.

ISO8601ToDateDef calls the TryISO8601ToDate function in its implementation.

## See also

DateToISO8601 |  | Converts a TDateTime value to ISO 8601 date/time format
TryISO8601ToDate |  | Attempts to convert an ISO 8601-formatted date/time value to a TDateTime type