note 102072 added to datetime.createfromformat

From: Date: Wed, 26 Jan 2011 09:46:34 +0000
Subject: note 102072 added to datetime.createfromformat
Groups: php.notes 
Request: Send a blank email to php-notes+get-176319@lists.php.net to get a copy of this message
Be aware the following does NOT return false, <?php $date = DateTime::createFromFormat("Y-m-d", "10-01-01"); ?> It instead returns a DateTime object with a date of "0010-01-01 09:14:39". I'm still conflicted as to whether this is a bug in the code, or whether it's a bug in the documentation. The docs for the "Y" format character clearly state, "A full numeric representation of a year, 4 digits" If I were to use format('Y-m-d') on a DateTime object with a year of 10, it would give me "0010-01-01", as expected. However it seems createFromFormat() ignores the 4 digits part of the rule, and behaves like "Y" is instead "A full numeric representation of a year", which for 10 would indeed be 10. Personally, I would expect the above code to return false as 10 is not a full 4 digit year. ---- Server IP: 69.147.83.197 Probable Submitter: 80.238.1.133 ---- Manual Page -- http://www.php.net/manual/en/datetime.createfromformat.php Edit -- https://master.php.net/note/edit/102072 Del: integrated -- https://master.php.net/note/delete/102072/integrated Del: useless -- https://master.php.net/note/delete/102072/useless Del: bad code -- https://master.php.net/note/delete/102072/bad+code Del: spam -- https://master.php.net/note/delete/102072/spam Del: non-english -- https://master.php.net/note/delete/102072/non-english Del: in docs -- https://master.php.net/note/delete/102072/in+docs Del: other reasons-- https://master.php.net/note/delete/102072 Reject -- https://master.php.net/note/reject/102072 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#176319) next »