[PHP-BUG] Bug #51737 [NEW]: Having a bug when using date_diff($t1,$t2)
From: Operating system: Win XP PHP version: 5.3.2 Package: *General Issues Bug Type: Bug Bug description:Having a bug when using date_diff($t1,$t2) Description: Hi, Sorry if not posting this bug in the correct section. I'm currently having a bug when using date_diff(). Seems that when the "day" part of the dates is the same on both dates compared, the function returns "0 Days" instead of 30 or some Days. Test script: --- $datetime1 = date_create('2010-03-08'); $datetime2 = date_create('2010-04-08'); $interval = date_diff($datetime1,$datetime2); echo $interval; //=> returns "+0 Days" // //Whereas // $datetime1 = date_create('2010-03-08'); $datetime2 = date_create('2010-04-07'); $interval = date_diff($datetime1,$datetime2); echo $interval; //Will return "+30 Days" Expected result: Should return "a whole month" interval like +31 Days in that particular case. Actual result: -- returns +0 Days -- Edit bug report at http://bugs.php.net/bug.php?id=51737&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=51737&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=51737&r=trysnapshot53 Try a snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=51737&r=trysnapshot60 Fixed in SVN: http://bugs.php.net/fix.php?id=51737&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=51737&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=51737&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=51737&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=51737&r=needscript Try newer version: http://bugs.php.net/fix.php?id=51737&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=51737&r=support Expected behavior: http://bugs.php.net/fix.php?id=51737&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=51737&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=51737&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=51737&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=51737&r=php4 Daylight Savings:http://bugs.php.net/fix.php?id=51737&r=dst IIS Stability: http://bugs.php.net/fix.php?id=51737&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=51737&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=51737&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=51737&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=51737&r=mysqlcfg
Bug #51737 [Fbk->Opn]: Having a bug when using date_diff($t1,$t2)
Edit report at http://bugs.php.net/bug.php?id=51737&edit=1 ID: 51737 User updated by: iggukk at gmail dot com Reported by: iggukk at gmail dot com Summary: Having a bug when using date_diff($t1,$t2) -Status: Feedback +Status: Open Type: Bug Package: Date/time related Operating System: Win XP PHP Version: 5.3.2 New Comment: Huh, sorry about that, and thanks for answering so quickly. echo $interval->format('%R%d days'); simply from the example on php manual. Just tried to feed the dates in different formats like 12.04.2010 and 12.03.2010, (instead of 2010-04-12) it seems to give the same result in final. Previous Comments: [2010-05-04 10:57:43] ahar...@php.net The test script you've provided doesn't work, since echoing a DateInterval object isn't supported. How are you actually outputting $interval? -------- [2010-05-04 10:33:23] iggukk at gmail dot com Description: Hi, Sorry if not posting this bug in the correct section. I'm currently having a bug when using date_diff(). Seems that when the "day" part of the dates is the same on both dates compared, the function returns "0 Days" instead of 30 or some Days. Test script: --- $datetime1 = date_create('2010-03-08'); $datetime2 = date_create('2010-04-08'); $interval = date_diff($datetime1,$datetime2); echo $interval; //=> returns "+0 Days" // //Whereas // $datetime1 = date_create('2010-03-08'); $datetime2 = date_create('2010-04-07'); $interval = date_diff($datetime1,$datetime2); echo $interval; //Will return "+30 Days" Expected result: Should return "a whole month" interval like +31 Days in that particular case. Actual result: -- returns +0 Days -- Edit this bug report at http://bugs.php.net/bug.php?id=51737&edit=1