简体   繁体   中英

Laravel DateTime error on fresh installation

I have install new version of 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

在此处输入图片说明

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'`

$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.

I solved it with

composer require nesbot/carbon

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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