|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2013-01-08 15:32 UTC] carlos dot jimene dot guirao at gmail dot com
Description:
------------
Working with DateTime object as shown on manual.
If you modify a DateTime object using this relative format "last day of December Year" it fails giving instead last day of next January.
It seems that it was corrected when used in DateTime Constructor instead. So if you create DateTime object using same string in constructor it works.
Test script:
---------------
$datetime = new DateTime();
$datetime->modify('last day of December 2012');
var_dump($datetime->format('Y-m-d'));
$anotherdt = new DateTime('last day of December 2012');
var_dump($anotherdt->format('Y-m-d'));
Expected result:
----------------
string(10) "2012-12-31"
string(10) "2012-12-31"
Actual result:
--------------
string(10) "2013-01-31"
string(10) "2012-12-31"
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 23 23:00:01 2025 UTC |
This issue might dependent on the timezone. Which one do you have set, Carlos? var_dump(ini_get('date.timezone'));