Question

I recently subscribed to OpenShift and deployed a new php 5.4 application, everything works fine, but I can't seem to change the default GMT php timezone.

Here's where this GMT timezone is defined:

> grep timezone ~/php/configuration/etc/php.ini

date.timezone = GMT

I'm able to edit this php.ini file and update the timezone to my desired value (America/Montreal), but as soon as the php cartridge is restarted (simply by doing a git push or issuing 'ctl_app restart' command on the server for ex), there's an unknown process that restores the php.ini back to openshift factory defaults, so I loose my changes and the timezone is back to GMT.

Any idea?

Thanks

Was it helpful?

Solution

You can use ini_set() to modify php.ini settings at run time. The modification will be valid only for the current run.

ini_set('date.timezone', 'america/new_york');
ini_set('date.timezone', 'europe/london');
ini_set('date.timezone', 'america/sao_paulo');
... etc.

This setting will affect behaviour of date and time functions like date().

Here is a list of supported timezones.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top