Home >>PHP Date Time Functions >PHP date_parse_from_format() Function
The date_parse_from_format() Function is used to get information about given date detailed information about a specified date, according to the specified format: It accepts two parameters and returns associative array with detailed information about given date.
Syntax:
date_parse_from_format(format, date)
Parameter | Description |
---|---|
format | This is required parameter. This parameter Specifies |
the format | (a format accepted by date_create_from_format()). |
date Required. | A string that specifies a date. |
Here is an exmaple of date_parse_from_format() Function in PHP:
<html> <body> <pre> <?php print_r(date_parse_from_format("mmddyyyy","9047291")); print_r(date_parse_from_format("j.n.Y H:iP","12.5.2013 14:35+02:00")); ?> </pre> </body> </html>
Array ( [year] => [month] => 47 [day] => 1 [hour] => [minute] => [second] => [fraction] => [warning_count] => 0 [warnings] => Array ( ) [error_count] => 1 [errors] => Array ( [7] => Data missing ) [is_localtime] => ) Array ( [year] => 2013 [month] => 5 [day] => 12 [hour] => 14 [minute] => 35 [second] => 0 [fraction] => [warning_count] => 0 [warnings] => Array ( ) [error_count] => 0 [errors] => Array ( ) [is_localtime] => 1 [zone_type] => 1 [zone] => 7200 [is_dst] => )
Example 2:
<html> <body> <pre> <?php print_r(date_parse_from_format("mmddyyyy","682478")); print_r(date_parse_from_format("j.n.Y H:iP","12.5.2013 14:35+02:00")); ?> <pre> </body> </html>
Array ( [year] => [month] => 24 [day] => 78 [hour] => [minute] => [second] => [fraction] => [warning_count] => 0 [warnings] => Array ( ) [error_count] => 1 [errors] => Array ( [6] => Data missing ) [is_localtime] => ) Array ( [year] => 2013 [month] => 5 [day] => 12 [hour] => 14 [minute] => 35 [second] => 0 [fraction] => [warning_count] => 0 [warnings] => Array ( ) [error_count] => 0 [errors] => Array ( ) [is_localtime] => 1 [zone_type] => 1 [zone] => 7200 [is_dst] => )