|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2013-11-29 11:37 UTC] derick@php.net
-Status: Open
+Status: Not a bug
[2013-11-29 11:37 UTC] derick@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 08 21:00:02 2026 UTC |
Description: ------------ As per manual DateTime::createFromFormat returns DateTime object or false. Test script: --------------- $sDate = "25.27.2013"; //d.m.Y format $mDateTime = DateTime::createFromFormat("d.m.Y", $sDate); if($mDateTime instanceof DateTime) { print("Date is ok!"); } else { print("Date not ok!"); } var_dump($mDateTime); var_dump(DateTime::getLastErrors()); Expected result: ---------------- Date not ok! $mDateTime = false; DateTime::getLastErrors() holds "The parsed date was invalid" message Actual result: -------------- Date is ok. (converted to 2015-03-25 10:57:26 which is weird but ok. can swallow that although it doesn't make any sense to calculate a "real" date from 25.27.2013 input to begin with) $mDateTime is DateTime object BUT! DateTime::getLastErrors() is: array(4) { ["warning_count"]=> int(1) ["warnings"]=> array(1) { [10]=> string(27) "The parsed date was invalid" } ["error_count"]=> int(0) ["errors"]=> array(0) { } } so there are erros in error array but the date is valid and is DateTime object instead of false!?