PHP中的date_parse()函数
date_parse()函数返回带有给定日期的详细信息的关联数组。
语法
date_parse(date)
参数
date-指定日期。
返回
date_parse()函数返回带有给定日期的详细信息的关联数组。
示例
以下是一个例子-
<?php print_r(date_parse("2017-11-08 11:10:40.5")); ?>
输出结果
以下是输出-
Array ( [year] => 2017 [month] => 11 [day] => 8 [hour] => 11 [minute] => 10 [second] => 40 [fraction] => 0.5 [warning_count] => 0 [warnings] => Array ( ) [error_count] => 0 [errors] => Array ( ) [is_localtime] => )
示例
让我们看另一个例子-
<?php print_r(date_parse("2017-10-10 11:00:00.5 +2 week +2 hour")); ?>
输出结果
以下是输出-
Array ( [year] => 2017 [month] => 10 [day] => 10 [hour] => 11 [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] => 14 [hour] => 2 [minute] => 0 [second] => 0 ) )