我可以在 Phing 中重置 PHP 时区设置吗?

Can I reset the PHP timezone settings in Phing?

我有一台无法更改 TZ 设置的服务器,以及一个包含 Tstamp 任务的 Phing build.xml,它会触发 PHP 时区警告:

[PHP Error] strftime(): It is not safe to rely on the system's timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. [line 159 of phar:///.../classes/phing/tasks/system/TstampTask.php]

我想抑制这个错误,但由于不允许我更改 php.ini 我想用另一种方式来做。简单的方法是在 运行ning Phing:

时为 php 提供新设置
php -d date.timezone=Europe/London phing.phar dbsetup

但是,我想在不指定 ini 设置的情况下执行此操作。我最初认为我可以 运行 一个 PHP 脚本作为另一个 <target>,但大概只是私下设置该脚本的设置,并且不会影响 Phing 核心的设置。

另一种方法是扩展 Tstamp 任务并为此在 Phing 配置中更改 class,但目前我是从默认 Phar 构建中 运行ning,所以也很理想!

我在 Git 上的 Phing 代码库中搜索了 date_default_timezone_set(),但它似乎不支持时区。

是否可能有一个 Phing 任务只使用指定的参数调用 ini_set()?或者有没有更好的方法来实现我想做的事情,而不是请求更改 Phing 核心?

这里有什么https://www.phing.info/docs/guide/trunk/PhpEvalTask.html?喜欢

<php expression="date_default_timezone_set('Europe/London');" />