【发布时间】:2015-09-23 18:16:26
【问题描述】:
以下代码抛出了一个我无法捕获的异常。
try {
$this->date = \Carbon\Carbon::parse($this->date)->toDateString();
}
catch (Exception $err) {
$this->date = \Carbon\Carbon::parse("January 1st 1900")->toDateString();
}
现在,如果我将它放在我的路由文件中的函数闭包中,它可以正常工作。仅在从模型调用时抛出异常。
exception 'Exception' with message 'DateTime::__construct(): Failed to parse time string (Summer 2015) at position 0 (S): The timezone could not be found in the database' in /home/vagrant/www/steamcompare/vendor/nesbot/carbon/src/Carbon/Carbon.php:222
还有其他人对 Carbon 有过这个问题吗?
【问题讨论】:
标签: php laravel laravel-5 php-carbon