I have a server that I cannot change TZ settings on, and a Phing build.xml
containing a Tstamp
task, which triggers the PHP timezone warning:
[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]
I'd like to suppress this error, but since I am not permitted to change php.ini
I'd like to do it another way. The trivial approach would be to supply new settings to php
when running Phing:
php -d date.timezone=Europe/London phing.phar dbsetup
However, I'd like to do that without specifying the ini setting. I initially thought I could just run a PHP script as another <target>
, but that presumably would just set the setting for that script privately, and would not affect the settings for the Phing core.
Another approach would be to extend the Tstamp
task and change the class for this in the Phing configuration, but presently I am running from the default Phar build, so that's ideally out too!
I've searched the Phing codebase on Git for date_default_timezone_set()
, but it does not seem to be timezone-aware.
Is there perhaps a Phing task that just calls ini_set()
with specified parameters? Or is there a better way to achieve what I want to do, short of requesting a change to the Phing core?
Anything from here https://www.phing.info/docs/guide/trunk/PhpEvalTask.html ? Like
<php expression="date_default_timezone_set('Europe/London');" />