|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2010-06-08 14:33 UTC] felipe@php.net
-Status: Open
+Status: Assigned
-Assigned To:
+Assigned To: derick
[2017-10-24 07:52 UTC] kalle@php.net
-Status: Assigned
+Status: Open
-Assigned To: derick
+Assigned To:
[2022-05-13 13:13 UTC] derick@php.net
-Status: Open
+Status: Closed
-Assigned To:
+Assigned To: derick
[2022-05-13 13:13 UTC] derick@php.net
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 05:00:02 2025 UTC |
Description: ------------ When using the DateTime class, it would make more sense to have getLastErrors be an instance method rather than a static method. That way, when creating a series of DateTime objects, you can check each one individually for errors. Currently it works as _documented_, but not in a very logical/useful way. Alternately, a getErrors() instance method that could sit alongside the getLastErrors() static method would be just as useful. Test script: --------------- <?php date_default_timezone_set('America/Los_Angeles'); $a = array( DateTime::createFromFormat('Y m d', '2009 01 31'), DateTime::createFromFormat('Y m d', '2009 02 28'), DateTime::createFromFormat('Y m d', '2009 02 29'), // 2009 not leap year DateTime::createFromFormat('Y m d', '2008 02 29'), // 2008 is leap year ); foreach ($a as $b) { print_r($b->getLastErrors()); } Expected result: ---------------- Array ( [warning_count] => 0 [warnings] => Array ( ) [error_count] => 0 [errors] => Array ( ) ) Array ( [warning_count] => 0 [warnings] => Array ( ) [error_count] => 0 [errors] => Array ( ) ) Array ( [warning_count] => 1 [warnings] => Array ( [10] => The parsed date was invalid ) [error_count] => 0 [errors] => Array ( ) ) Array ( [warning_count] => 0 [warnings] => Array ( ) [error_count] => 0 [errors] => Array ( ) ) Actual result: -------------- Array ( [warning_count] => 0 [warnings] => Array ( ) [error_count] => 0 [errors] => Array ( ) ) Array ( [warning_count] => 0 [warnings] => Array ( ) [error_count] => 0 [errors] => Array ( ) ) Array ( [warning_count] => 0 [warnings] => Array ( ) [error_count] => 0 [errors] => Array ( ) ) Array ( [warning_count] => 0 [warnings] => Array ( ) [error_count] => 0 [errors] => Array ( ) )