The date_parse() is an inbuilt function in PHP which is used to find the detailed information about a specified date. This function returns an associative array of detailed information for a specified date on success and returns FALSE on failure
Syntax:
date_parse($date)
Parameters Used: The date_parse() function accepts only one parameter as mentioned above and described below:
- $date: It is a mandatory parameter which specifies the date (in a format accepted by strtotime() function)
Return Value: Returns an associative array containing information about the parsed date.
Errors/Exceptions: In case if the date format has an error, an error message will appear.
Below programs illustrate the date_parse() function.
Program 1:
<?php // PHP program to illustrate // the date_parse function print_r(date_parse("2018-06-27 12:30:45.5")); ?> |
Array
(
[year] => 2018
[month] => 6
[day] => 27
[hour] => 12
[minute] => 30
[second] => 45
[fraction] => 0.5
[warning_count] => 0
[warnings] => Array
(
)
[error_count] => 0
[errors] => Array
(
)
[is_localtime] =>
)
Program 2: If we Passing incorrect format of date in function then program run successfully but it will count errors. below program show [error_count] =gt; 1.
<?php // PHP program to illustrate // the date_parse function // Passing incorrect format of date then // it will gives errors. // [error_count] => 1 print_r(date_parse("2018-18-18")); ?> |
Array
(
[year] => 2018
[month] => 1
[day] => 1
[hour] =>
[minute] =>
[second] =>
[fraction] =>
[warning_count] => 0
[warnings] => Array
(
)
[error_count] => 1
[errors] => Array
(
[6] => Unexpected character
)
[is_localtime] => 1
[zone_type] => 1
[zone] => 1080
[is_dst] =>
)
Reference: http://php.net/manual/en/function.date-parse.php
Recommended Posts:
- How to Check a Function is a Generator Function or not using JavaScript ?
- How to call a function that return another function in JavaScript ?
- How to get the function name from within that function using JavaScript ?
- How to get the function name inside a function in PHP ?
- p5.js | tan() function
- p5.js | log() function
- D3.js | d3.sum() function
- D3.js | d3.mean() function
- PHP | ord() Function
- p5.js | sin() function
- D3.js | d3.map.set() Function
- p5.js | hex() function
- D3.js now() function
- D3.js | d3.set.has() Function
- PHP | dir() Function
- CSS | var() Function
- PHP | pow( ) Function
- p5.js | int() function
- p5.js | str() function
- p5.js | cos() function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : nidhi_biet

