wwUtils::ToIsoDateString

Converts a FoxPro date or date time or string value to ISO 8601 format: 2012-10-08 or 2014-10-01T16:55:12Z. Dates can be created with or without UTC time offsets.

This function is useful for converting dates to the format required by HTML5 input type=date controls which can only display dates using the standard ISO formatting.

ToIsoDateString(ldDate, llIncludeTime, llNoUtc)

Return Value

formatted date

Parameters

ldDate
A FoxPro date or DateTime value or a time string

Examples:

  • 2015-10-23
  • 2015-12-01T16:10:10 (llIncludeTime .t. llNoUtc .t.)
  • 2015-12-01T21:10:10Z (llIncludeTime .t. llNoUtc .f.)

llIncludeTime
if .T. returns both date and time portions.

llNoUtc
if .T. creates the date as a local date time. If .F. (default) date is converted to UTC date and a Z is appended to the return string.

Example

? ToIsoDateString(DATETIME())
* 2015-10-27

? ToIsoDateString(DATETIME(),.T.)
* 2015-10-27T18:12:54Z

? ToIsoDateString(DATETIME(),.T.)
* 2015-10-27T18:12:54Z

? ToIsoDateString(DATETIME(),.T.,.T.)
* 2015-10-27T10:12:54

? ToIsoDateString("10/10/2015")
* 2015-10-10

? ToIsoDateString("10/10/2015 10:10am",.T.)
* 2015-10-10T18:10:00Z

? ToIsoDateString("10/10/2015 15:10",.T.)
* 2015-10-10T23:10:00Z

See also:

Class wwUtils

© West Wind Technologies, 2023 • Updated: 10/27/15
Comment or report problem with topic