note 113204 added to dateinterval.format

From: Date: Thu, 12 Sep 2013 10:58:55 +0000
Subject: note 113204 added to dateinterval.format
Groups: php.notes 
Request: Send a blank email to php-notes+get-196238@lists.php.net to get a copy of this message
How to easy recalculate carry over points: <?php class DateIntervalEnhanced extends DateInterval { public function recalculate() { $from = new DateTime; $to = clone $from; $to = $to->add($this); $diff = $from->diff($to); foreach ($diff as $k => $v) $this->$k = $v; return $this; } } $di = new DateIntervalEnhanced('PT3600S'); echo "Instead of " . $di->format('%h:%i:%s') . " it outputs " . $di->recalculate()->format('%h:%i:%s'); # output will be: "Instead of 0:0:3600 it outputs 1:0:0" ---- Server IP: 69.147.83.199 Probable Submitter: 92.63.27.15 ---- Manual Page -- http://php.net/manual/en/dateinterval.format.php Edit -- https://master.php.net/note/edit/113204 Del: integrated -- https://master.php.net/note/delete/113204/integrated Del: useless -- https://master.php.net/note/delete/113204/useless Del: bad code -- https://master.php.net/note/delete/113204/bad+code Del: spam -- https://master.php.net/note/delete/113204/spam Del: non-english -- https://master.php.net/note/delete/113204/non-english Del: in docs -- https://master.php.net/note/delete/113204/in+docs Del: other reasons-- https://master.php.net/note/delete/113204 Reject -- https://master.php.net/note/reject/113204 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#196238) next »