PHP 日期和时间函数

PHP date_parse_from_format()函数用于以指定格式解析一个日期,并返回关联数组。

语法

date_parse_from_format(format,date); 

    参数

    参数描述必须/可选
    format指定格式 格式参考必须
    date指定日期必须

    返回值

    此函数返回包含给定日期详细信息的关联数组。

    例子

    <?php
    print_r(date_parse_from_format("Y/m/d H:i:s","2023-03-15 12:13:59"));
    ?>  
    • 1
    • 2

    输出:

    Array
    (
        [year] => 2023
        [month] => 3
        [day] => 15
        [hour] => 12
        [minute] => 13
        [second] => 59
        [fraction] => 
        [warning_count] => 0
        [warnings] => Array
            (
            )

        [error_count] => 4
        [errors] => Array
            (
                [4] => Unexpected data found.
                [7] => Unexpected data found.
            )

        [is_localtime] => 
    )