|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2010-02-12 20:02 UTC] m dot kurzyna at crystalpoint dot pl
Description:
------------
DateInterval::format() does not handle "carry over points" thus having 25 hours or 70 minutes is a valid output. Format description suggests that output would be recalculated (but specifying min,middle,max sample outputs).
Submitted as documentation problem but IMHO the implementation could be changed (at least be optional whether to recalculate carry overs or not).
Reproduce code:
---------------
<?php
$dti = new \DateInterval('PT70M');
echo $dti->format('%H:%I:%S');
?>
Expected result:
----------------
01:10:00
Actual result:
--------------
00:70:00
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 08 15:00:02 2026 UTC |
Aye. And i admit i haven't thought of that - feel free to mark me bogus ;-) Leap years also come to mind now; as i was fixed on the time issue which i have run into i haven't considered dates at all. I'd still vote on documentation clarification there though; and maybe giving your explanation as well. As a side note - i was experimenting with date manipulation (in order to check whether combination of DateTime::add()/diff() would yield what i need) and have run into another (sort of) ambiguity: $today = new DateTime(); $tomorrow = $today ->add(new DateInterval('P1D'); $today is $tomorrow (as in same object). I didn't expect that only by examining documentation. I'd change: Return Values Returns the modified DateTime. to: Return Values Returns the modified self object (DateTime). I love the ability to do chain calls and actually like this feature - it's just i haven't expected it from core. No real statistics behind it but i have a feeling that most PHP functions don't return self references. Take SimpleXMLElement::addChild() for example as it's a similar case. It returns added child not "self" containing the added child. No matter - just wondering off there. Point is: please be so kind and consider documentation enhancements (although i admit it's not a very critical case and based mostly on my assumptions on how things will work).