date_parse_from_format

Get info about given date formatted according to the specified format

Syntax

date_parse_from_format ( string $format , string $date ) : array

Parameters

format

Format accepted by DateTime::createFromFormat().

date

String representing the date.

Return

Returns associative array with detailed info about given date.

Examples

<?

$format = "j.n.Y H:i:sP";
$date = "3.2.2001 04:05:06+07:00";

$return = date_parse_from_format($format, $date);

print_r($return);

?>
Array
(
    [year] => 2001
    [month] => 2
    [day] => 3
    [hour] => 4
    [minute] => 5
    [second] => 6
    [fraction] => 0
    [warning_count] => 0
    [warnings] => Array
        (
        )

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

    [is_localtime] => 1
    [zone_type] => 1
    [zone] => 25200
    [is_dst] => 
)

PHP

Home Menu