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"));
?>
输出:
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] =>
)
(
[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] =>
)