语法错误,意外的标识符 DateTimeZone,期望变量。

huangapple go评论60阅读模式
英文:

syntax error, unexpected identifier DateTimeZone, expecting variable

问题

我删除了 vendor 文件夹,然后重新安装了 Composer,但仍然出现错误。
Laravel 版本是 8.75,PHP 版本是 8.0.25。
有人可以帮忙吗?
提前感谢!

语法错误,意外的标识符 DateTimeZone,期望变量。

英文:

after updating composer i'm getting this error.

i delete the vendor folder and again install the composer but still have erorr .
Laravel version is 8.75
php version is 8.0.25
could someone help ?
thanks in advance语法错误,意外的标识符 DateTimeZone,期望变量。

答案1

得分: 0

只安装版本2.1.0的lcobucci/clock

你可以通过composer安装

composer require lcobucci/clock:2.1.0

英文:

Just install version 2.1.0 of lcobucci/clock

You can install it via composer

composer require lcobucci/clock:2.1.0

答案2

得分: 0

我遇到了相同的问题,在我的情况下,我正在使用PHP 8.2和PHP-FPM 8.0,所以我在nginx配置中将php-fpm更改为8.2,就像PHP一样。

最后,问题得到解决。

英文:

I had the same problem, in my case, I was using PHP 8.2 and PHP-FPM 8.0 so I changed php-fpm in the nginx configuration to 8.2 like PHP.

And finally, solve the problem.

答案3

得分: 0

升级 PHP 版本从 8.0 到 8.1 问题已解决。

英文:

after upgrading PHP version from 8.0 to 8.1 issue is resolved

答案4

得分: -1

尝试这个...

```php
<?php

use DateTime;
use DateTimeZone;

// 创建一个具有特定时区的新 DateTime 对象
$date = new DateTime();
$date->setTimezone(new DateTimeZone('America/New_York'));

// 获取当前日期和时间
$currentDateTime = $date->format('Y-m-d H:i:s');
dd($currentDateTime);
?>
英文:

Try this..

&lt;?php

use DateTime;
use DateTimeZone;

**// Create a new DateTime object with a specific timezone**
$date = new DateTime();
$date-&gt;setTimezone(new DateTimeZone(&#39;America/New_York&#39;));

// Retrieve the current date and time
$currentDateTime = $date-&gt;format(&#39;Y-m-d H:i:s&#39;);
dd($currentDateTime);
?&gt;

huangapple
  • 本文由 发表于 2023年6月19日 16:20:20
  • 转载请务必保留本文链接:https://go.coder-hub.com/76504838.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定