date_parse
date_parse
(PHP 5 >= 5.2.0, PHP 7)
date_parse - 返回关于给定日期的详细信息的关联数组
Description
array date_parse ( string $date )
Parameters
date
strtotime()接受的格式的日期。
Return Values
返回包含成功时解析日期信息的数组或FALSE
失败。
Errors/Exceptions
如果日期格式有错误,则元素“错误”将包含错误消息。
Examples
Example #1 A date
_
parse() example
<?php
print_r(date_parse("2006-12-12 10:00:00.5")
?>
上面的例子将输出:
Array
(
[year] => 2006
[month] => 12
[day] => 12
[hour] => 10
[minute] => 0
[second] => 0
[fraction] => 0.5
[warning_count] => 0
[warnings] => Array()
[error_count] => 0
[errors] => Array()
[is_localtime] =>
)
相对格式不会影响从绝对格式解析的值,但会被解析为“相对”元素。
Example #2 date
_
parse() with relative formats
<?php
print_r(date_parse("2006-12-12 10:00:00.5 +1 week +1 hour")
?>
上面的例子将输出:
Array
(
[year] => 2006
[month] => 12
[day] => 12
[hour] => 10
[minute] => 0
[second] => 0
[fraction] => 0.5
[warning_count] => 0
[warnings] => Array
(
)
[error_count] => 0
[errors] => Array
(
)
[is_localtime] =>
[relative] => Array
(
[year] => 0
[month] => 0
[day] => 7
[hour] => 1
[minute] => 0
[second] => 0
)
)
← date_parse_from_format
date_sub →
© 1997–2017 The PHP Documentation Group
根据知识共享署名许可证v3.0或更高版本授权。