php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #66485 01.01.2014 diff 01.02.2014 is 30 days instead of 1 month
Submitted: 2014-01-14 12:44 UTC Modified: 2017-04-24 15:52 UTC
Votes:2
Avg. Score:4.0 ± 1.0
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (50.0%)
From: kuba at pdesign dot pl Assigned: derick (profile)
Status: Duplicate Package: Date/time related
PHP Version: 5.5.8 OS: Windows 7
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: kuba at pdesign dot pl
New email:
PHP Version: OS:

 

 [2014-01-14 12:44 UTC] kuba at pdesign dot pl
Description:
------------
---
From manual page: http://www.php.net/datetime.diff
---

see the actual result

Test script:
---------------
// date format DD-MM-YYYY
$start = new DateTime('01-02-2014');
$stop = new DateTime('01-03-2014');
$diff = $start->diff($stop);
echo $diff->format('%d days %m months');

Expected result:
----------------
0 days 1 months

Actual result:
--------------
28 days 0 months

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-01-14 13:11 UTC] derick@php.net
-Assigned To: +Assigned To: derick
 [2014-11-19 09:02 UTC] mike@php.net
-Package: Output Control +Package: Date/time related
 [2015-11-09 08:23 UTC] jimmy dot gaussen at gmail dot com
Hi,

I had the same issue on 5.6.10, on Linux and Winndows. I tried to do some research on it, here is the dead r/PHPHelp thread I opened:

https://www.reddit.com/r/PHPhelp/comments/3r7so6/weird_datetimediff_interaction_with_time_zones/
 [2017-04-24 15:52 UTC] heiglandreas@php.net
-Status: Assigned +Status: Duplicate
 [2017-04-24 15:52 UTC] heiglandreas@php.net
This looks like a duplicate of https://bugs.php.net/bug.php?id=52480
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 04:01:29 2024 UTC