Home >>PHP Date Time Functions >PHP date_parse() Function

PHP date_parse() Function

PHP date_parse() Function

PHP date_parse() Function is used to find the detailed information about a specified date. It returns an associative array of detailed information for a specified date on success otherwise, it returns FALSE on failure.

Syntax:

 date_parse(date);

Parameter Values

Parameter Description
date This is a required parameter. This parameter defines a date in a format accepted by strtotime().

Here is a exmaple of date_parse() Function in PHP:

<html>
<body>
<pre>
<?php
print_r(date_parse("2020-01-31 12:30:45"));
?>
</pre>
</body>
</html>
Output:
Array
(
    [year] => 2020
    [month] => 1
    [day] => 31
    [hour] => 12
    [minute] => 30
    [second] => 45
    [fraction] => 0
    [warning_count] => 0
    [warnings] => Array
        (
        )

    [error_count] => 0
    [errors] => Array
        (
        )

    [is_localtime] => 
)

Example2:

<html>
<body>
<pre>
<?php
print_r(date_parse("2020-06-10 10:40:45"));
?>
</pre>
</body>
</html>
Output:
Array
(
    [year] => 2020
    [month] => 6
    [day] => 10
    [hour] => 10
    [minute] => 40
    [second] => 45
    [fraction] => 0
    [warning_count] => 0
    [warnings] => Array
        (
        )

    [error_count] => 0
    [errors] => Array
        (
        )

    [is_localtime] => 
)

No Sidebar ads