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

 ID:                 60774
 Updated by:         ni...@php.net
 Reported by:        wodor at wodor dot net
 Summary:            DateInterval::format("%a") unknown or zero
-Status:             Open
+Status:             Closed
 Type:               Bug
 Package:            Date/time related
 Operating System:   Linux/Windows
 PHP Version:        5.3.9
-Assigned To:        
+Assigned To:        nikic
 Block user comment: N
 Private report:     N

 New Comment:

Fixed, see https://github.com/php/php-src/pull/148.


Previous Comments:
------------------------------------------------------------------------
[2012-01-16 20:33:28] wodor at wodor dot net

Description:
------------
similiar to fixed (?) bug  #49778 

when \DateInterval is created in any other way than \DateTime::diff it fails 
when asked for number of days (%a) 

seen also on :
PHP 5.3.2-1ubuntu4.11 with Suhosin-Patch (cli) (built: Dec 13 2011 18:45:32) 
there i get:
diff:2
string:0
construct:0


PHP 5.3.6-13ubuntu3.3 with Suhosin-Patch (cli) (built: Dec 13 2011 18:18:37)
there i get the same as on windows 5.3.9


no changes made in config during test on windows, beside the timezone was set 
to Europe/Warsaw by function before code
http://windows.php.net/downloads/releases/php-5.3.9-nts-Win32-VC9-x86.zip 





Test script:
---------------
<?php
$now = new \DateTime();
$before = new \DateTime('-2 days');

$intervalFromDiff = $before->diff($now);
$intervalFromString= \DateInterval::createFromDateString("2 days");
$intervalFromConstruct= new \DateInterval("P2D");


echo "\n diff:".$intervalFromDiff->format("%a");
echo "\n string:".$intervalFromString->format("%a");
echo "\n construct:".$intervalFromConstruct->format("%a");


Expected result:
----------------
 diff:2
 string:2
 construct:2

Actual result:
--------------
 diff:2
 string:0
 construct:(unknown)


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



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

Reply via email to