note 113270 deleted from class.dateinterval by cmb
| From: | cmb@php.net | Date: | Tue, 14 Jun 2016 10:45:14 +0000 |
| Subject: | note 113270 deleted from class.dateinterval by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-205718@lists.php.net to get a copy of this message | ||
Note Submitter: till at php dot net
----
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");
}
?>