Search code examples
phpdatezend-framework2

ZendFramework 2 : Set date_default_timezone


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.


Solution

  • The best way is to set it in your php.ini file. This will be for php wide (both web and cli), for all applications and directly available. The timezone of php should be a server wide setting, so it is not strange to put it in a server wide config (the php.ini) as well.

    Search for date.timezone in your php.ini. You can read more about it in the manual. An example is date.timezone = UTC.