|
date_parseReturns associative array with detailed info about given date/time Descriptionarray date_parse(string
$datetime )
date_parse parses the given
If no information about a certain group of elements can be found, these
array elements will be set to Parameters
Return ValuesReturns array with information about the parsed date/time.
The returned array has keys for
If
If relative time elements are present in the
The array includes
The array also contains Warning
The number of array elements in the Errors/ExceptionsIn case the date/time format has an error, the element 'errors' will contain the error messages. Changelog
Examples
Example #1 A date_parse example with a comprehensive
The above example will output: array(12) { ["year"]=> int(2006) ["month"]=> int(12) ["day"]=> int(12) ["hour"]=> int(10) ["minute"]=> int(0) ["second"]=> int(0) ["fraction"]=> float(0.5) ["warning_count"]=> int(0) ["warnings"]=> array(0) { } ["error_count"]=> int(0) ["errors"]=> array(0) { } ["is_localtime"]=> bool(false) }
The timezone elements only show up if they are included in the given
Example #2 date_parse with timezone abbreviation information
The above example will output: array(16) { ["year"]=> int(2022) ["month"]=> int(6) ["day"]=> int(2) ["hour"]=> int(10) ["minute"]=> int(28) ["second"]=> int(17) ["fraction"]=> float(0) ["warning_count"]=> int(0) ["warnings"]=> array(0) { } ["error_count"]=> int(0) ["errors"]=> array(0) { } ["is_localtime"]=> bool(true) ["zone_type"]=> int(2) ["zone"]=> int(0) ["is_dst"]=> bool(true) ["tz_abbr"]=> string(3) "BST" } Example #3 date_parse with timezone identifier information
The above example will output: array(14) { ["year"]=> int(2022) ["month"]=> int(6) ["day"]=> int(2) ["hour"]=> int(10) ["minute"]=> int(28) ["second"]=> int(17) ["fraction"]=> float(0) ["warning_count"]=> int(0) ["warnings"]=> array(0) { } ["error_count"]=> int(0) ["errors"]=> array(0) { } ["is_localtime"]=> bool(true) ["zone_type"]=> int(3) ["tz_id"]=> string(13) "Europe/London" }
If a more minimal Example #4 date_parse with a minimal string
The above example will output: array(12) { ["year"]=> int(2022) ["month"]=> int(6) ["day"]=> int(2) ["hour"]=> bool(false) ["minute"]=> bool(false) ["second"]=> bool(false) ["fraction"]=> bool(false) ["warning_count"]=> int(0) ["warnings"]=> array(0) { } ["error_count"]=> int(0) ["errors"]=> array(0) { } ["is_localtime"]=> bool(false) } Relative formats do not influence the values parsed from absolute formats, but are parsed into the "relative" element. Example #5 date_parse with relative formats
The above example will output: array(13) { ["year"]=> int(2006) ["month"]=> int(12) ["day"]=> int(12) ["hour"]=> int(10) ["minute"]=> int(0) ["second"]=> int(0) ["fraction"]=> float(0.5) ["warning_count"]=> int(0) ["warnings"]=> array(0) { } ["error_count"]=> int(0) ["errors"]=> array(0) { } ["is_localtime"]=> bool(false) ["relative"]=> array(6) { ["year"]=> int(0) ["month"]=> int(0) ["day"]=> int(7) ["hour"]=> int(1) ["minute"]=> int(0) ["second"]=> int(0) } }
Some stanzas, such as Example #6 date_parse with side-effects
The above example will output: array(13) { ["year"]=> bool(false) ["month"]=> int(6) ["day"]=> int(2) ["hour"]=> int(0) ["minute"]=> int(0) ["second"]=> int(0) ["fraction"]=> float(0) ["warning_count"]=> int(0) ["warnings"]=> array(0) { } ["error_count"]=> int(0) ["errors"]=> array(0) { } ["is_localtime"]=> bool(false) ["relative"]=> array(7) { ["year"]=> int(0) ["month"]=> int(0) ["day"]=> int(0) ["hour"]=> int(0) ["minute"]=> int(0) ["second"]=> int(0) ["weekday"]=> int(4) } } See Also
|