I am new to the Zend Framework 2 and would like to simply know if there is a global way of setting the date default timezone.
I am aware that i should just be able to add the code:
date_default_timezone_set("UTC");
However i have been looking for about an hour and can't find an answer addressing this issue.
I have also tried by setting this in the php.ini but i'm not sure if this would suppress the error message.
Thanks in advance.
My "elegant way" is overwriting php settings from config file using onBootstrap. Inside my global.php I add the php settings I need to set up for the app:
return array(
'php_settings' => array(
'date.timezone' => 'UTC',
'memory_limit' => '128M',
'display_errors' =>'On'
)
);
Then, onBootstrap:
//Enable php settings from config file into the web app
$services = $e->getApplication()->getServiceManager();
$config = $services->get('config');
$phpSettings = $config['php_settings'];
if ($phpSettings) {
foreach ($phpSettings as $key => $value) {
ini_set($key, $value);
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With