简体   繁体   English

全新安装上的Laravel DateTime错误

[英]Laravel DateTime error on fresh installation

I have install new version of Laravel. 我已经安装了新版本的Laravel。 After opening it is OK. 打开后就可以了。 But If after some time I try to refresh or try to visit another page, it is showing an error. 但是,如果一段时间后我尝试刷新或尝试访问另一个页面,则显示错误。 If I restart the server, then for few minutes it is again OK. 如果我重新启动服务器,则几分钟后它仍然可以。 Older version was OK, this problem I am facing for the first time. 较旧的版本还可以,我第一次遇到这个问题。 Please help. 请帮忙。

ERROR: 错误:

(1/1) Exception DateTime::__construct(): Failed to parse time string (2018-03-10 11:07:55.-811414) at position 24 (4): Unexpected character (1/1)异常DateTime :: __ construct():无法解析位置24(4)上的时间字符串(2018-03-10 11:07:55.-811414):意外字符

在此处输入图片说明

Simply generate app key, write in console: 只需生成应用程序密钥,在控制台中编写:

php artisan key:generate

The "right" way defining default datetimes 定义默认日期时间的“正确”方法

$datetime = new DateTime('2014-06-23');

You can also use a hack using pages.dateformat.default: 'md-Y'` 您也可以使用pages.dateformat.default:'md-Y'`

$datetime = DateTime::createFromFormat('m-d-Y', '06-23-2014');

I had the same problem with fresh install of Laravel 5.4 and PHP 5.6. 全新安装Laravel 5.4和PHP 5.6时遇到相同的问题。

I solved it with 我解决了

composer require nesbot/carbon

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM