php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #60774 DateInterval::format("%a") unknown or zero
Submitted: 2012-01-16 20:33 UTC Modified: 2013-04-26 08:07 UTC
Votes:7
Avg. Score:3.4 ± 0.7
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:0 (0.0%)
From: wodor at wodor dot net Assigned: nikic (profile)
Status: Closed Package: Date/time related
PHP Version: 5.3.9 OS: Linux/Windows
Private report: No CVE-ID: None
 [2012-01-16 20:33 UTC] 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)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-04-26 08:07 UTC] nikic@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: nikic
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 12:01:31 2024 UTC