Bug #73120 [Fbk->NoF]: Wrong calculation

From: Date: Sun, 26 Feb 2017 04:22:30 +0000
Subject: Bug #73120 [Fbk->NoF]: Wrong calculation
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-207557@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=73120&edit=1

 ID:               73120
 Updated by:       php-bugs@lists.php.net
 Reported by:      carletto90 at gmail dot com
 Summary:          Wrong calculation
-Status:           Feedback
+Status:           No Feedback
 Type:             Bug
 Package:          Date/time related
 Operating System: Windows 10
 PHP Version:      7.0.11
 Private report:   N

 New Comment:

No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.


Previous Comments:
------------------------------------------------------------------------
[2017-02-12 18:12:48] derick@php.net

Not enough information was provided for us to be able
to handle this bug. Please re-read the instructions at
http://bugs.php.net/how-to-report.php

If you can provide more information, feel free to add it
to this bug and change the status back to "Open".

Thank you for your interest in PHP.


I can't reproduce this:

derick@whisky:~/dev/timelib $ php
<?php

$date = new \DateTime('2016-03-01');
$date2 = new \DateTime('2016-03-31');
$diff = $date->diff($date2);

echo 'Years: '.$diff->y."\n";
echo 'Months: '.$diff->m."\n";
echo 'Days: '.$diff->d."\n";

?>
Years: 0
Months: 0
Days: 30

Which timezone have you configured?

------------------------------------------------------------------------
[2016-11-25 19:31:47] jhdxr@php.net

the current result is strange, but why the correct result is 1 month? 

2016-03-31  -  2016-03-01 ==> 30 days
2016-04-01  -  2016-03-01 ==> 1 month

I think this is the correct calculation.

------------------------------------------------------------------------
[2016-09-20 08:25:18] carletto90 at gmail dot com

Description:
------------
---
From manual page: http://www.php.net/datetime.diff
---


Test script:
---------------
<?php

$date = new \DateTime('2016-03-01');
$date2 = new \DateTime('2016-03-31');
$diff = $date->diff($date2);

echo 'Years: '.$diff->y."\n";
echo 'Months: '.$diff->m."\n";
echo 'Days: '.$diff->d."\n";

?>

Expected result:
----------------
Years: 0
Months: 1
Days: 0

Actual result:
--------------
Years: 0
Months: 1
Days: 1


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=73120&edit=1


Thread (4 messages)

« previous php.bugs (#207557) next »