date_parse_from_format in PHP

Syntax of date_parse_from_format

array date_parse_from_format(string format, string time)

Parses time into an associative array representing a date. The string time is given in the format specified by format, using the same character codes as described in date(). The returned array contains the following entries:

year Year
month Month
day Day of the month
hour Hours
minute Minutes
second Seconds
fraction Fractions of seconds
warning_count Number of warnings that occurred during parsing
warnings An array of warnings that occurred during parsing
error_count Number of errors that occurred during parsing
errors An array of errors that occurred during parsing
is_localtime True if the time represents a time in the current default time zone
zone_type The type of time zone zone represents

zone The time zone the time is in
is_dst True if the time represents a time in Daylight Savings Time

Example of date_parse_from_format

<?php
$date = "6.1.2009 13:00+01:00";
print_r(date_parse_from_format("j.n.Y H:iP", $date));
?>
Array
(
    [year] => 2009
    [month] => 1
    [day] => 6
    [hour] => 13
    [minute] => 0
    [second] => 0
    [fraction] => 
    [warning_count] => 0
    [warnings] => Array
        (
        )

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

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

Leave a Comment