|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2015-05-19 11:17 UTC] php-bugs at xpaw dot me
Description:
------------
I don't know if this is expected behaviour or not, but parsing a date without a day, will produce a result where 'day' will be set to 1. If this is expected, there really should be a parameter that disables this. I'm using this for user provided data, and it's not really valid.
Test script:
---------------
var_dump(date_parse("May 2013"));
Expected result:
----------------
["day"]=>
bool(false)
Actual result:
--------------
["day"]=>
int(1)
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 22:00:01 2025 UTC |
If you want more control over parsing dates, where the behaviour of strtotime/ the DateTime constructor does not apply, you can use the date_parse_from_format function, like: php -r 'var_dump(date_parse_from_format("M Y", "May 2013"));' This will then show you the right information: array(12) { 'year' => int(2013) 'month' => int(5) 'day' => bool(false)