note 113270 added to class.dateinterval

From: Date: Thu, 19 Sep 2013 14:20:32 +0000
Subject: note 113270 added to class.dateinterval
Groups: php.notes 
Request: Send a blank email to php-notes+get-196313@lists.php.net to get a copy of this message
It should be noted that the following code will not throw an exception or return false, or anything: <?php $interval = new \DateInterval::createFromDateString("this is not a date interval"); ?> Your best way to check if what you created is a "valid" interval, by doing something like the following: <?php $interval = new \DateInterval::createFromDateString("this is not a date interval"); if (0 == $interval->format('s')) { throw new \LogicException("Wrong interval"); } ?> ---- Server IP: 69.147.83.199 Probable Submitter: 87.149.190.133 ---- Manual Page -- http://php.net/manual/en/class.dateinterval.php Edit -- https://master.php.net/note/edit/113270 Del: integrated -- https://master.php.net/note/delete/113270/integrated Del: useless -- https://master.php.net/note/delete/113270/useless Del: bad code -- https://master.php.net/note/delete/113270/bad+code Del: spam -- https://master.php.net/note/delete/113270/spam Del: non-english -- https://master.php.net/note/delete/113270/non-english Del: in docs -- https://master.php.net/note/delete/113270/in+docs Del: other reasons-- https://master.php.net/note/delete/113270 Reject -- https://master.php.net/note/reject/113270 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#196313) next »