DateTime::getLastErrors

date_get_last_errors

(PHP 5 >= 5.3.0, PHP 7)

DateTime::getLastErrors -- date_get_last_errors锟斤拷取锟斤拷锟斤拷痛锟斤拷锟斤拷锟较�

说锟斤拷

锟斤拷锟斤拷锟斤拷锟斤拷锟�

public static DateTime::getLastErrors ( void ) : array

锟斤拷锟教伙拷锟斤拷锟�

date_get_last_errors ( void ) : array

锟斤拷锟斤拷锟节斤拷锟斤拷锟斤拷锟斤拷时锟斤拷锟街凤拷锟斤拷锟侥癸拷锟斤拷锟叫凤拷锟斤拷锟侥撅拷锟斤拷痛锟斤拷锟斤拷锟较拷锟�

锟斤拷锟斤拷

锟剿猴拷锟斤拷没锟叫诧拷锟斤拷锟斤拷

锟斤拷锟斤拷值

锟斤拷锟斤拷一锟斤拷锟斤拷锟介,锟斤拷锟叫帮拷锟斤拷锟节斤拷锟斤拷锟斤拷锟斤拷时锟斤拷锟街凤拷锟斤拷锟侥癸拷锟斤拷锟叫凤拷锟斤拷锟侥撅拷锟斤拷痛锟斤拷锟斤拷锟较拷锟�

锟斤拷锟斤拷

Example #1 DateTime::getLastErrors() 锟斤拷锟斤拷

锟斤拷锟斤拷锟斤拷锟斤拷锟�

<?php
try {
    
$date = new DateTime('asdfasdf');
} catch (
Exception $e) {
    
// 锟斤拷锟斤拷锟斤拷锟斤拷示锟斤拷目锟斤拷...
    
print_r(DateTime::getLastErrors());

    
// 实锟绞的达拷锟斤拷锟斤拷锟斤拷应锟斤拷锟斤拷锟斤拷使锟矫凤拷锟截讹拷锟斤拷
    // echo $e->getMessage();
}
?>

锟斤拷锟教伙拷锟斤拷锟�

<?php
$date 
date_create('asdfasdf');
print_r(date_get_last_errors());
?>

锟斤拷锟斤拷锟斤拷锟教伙拷锟斤拷锟斤拷锟�

Array
(
   [warning_count] => 1
   [warnings] => Array
       (
           [6] => Double timezone specification
       )

   [error_count] => 1
   [errors] => Array
       (
           [0] => The timezone could not be found in the database
       )

)

锟斤拷锟斤拷锟斤拷锟斤拷锟叫碉拷锟斤拷锟斤拷 6 锟斤拷 0 锟斤拷示锟节斤拷锟斤拷锟斤拷锟斤拷锟叫o拷锟斤拷锟结供锟斤拷锟斤拷锟斤拷时锟斤拷锟街凤拷锟斤拷锟斤拷锟睫凤拷锟斤拷确锟斤拷锟斤拷锟斤拷锟街凤拷位锟矫★拷