Set the default timezone in symfony

不羁岁月 提交于 2019-12-12 22:16:04

问题


i want to know how can i set timezone for an entire project?

i'm using symfony 1.4 with doctrine and i have a problem with datetime saving.
whenever i save a record, it's time is not correct and i know that's because of timezone.

i know i can use date_default_timezone_set() function to set default timezone, but i have to do it in every single action that i'm using date and it's not right.

is there an easier way to do it? i think doctrine should have something to set it automatically but i don't know how.


回答1:


The symfony way is to use default_timezone in settings.yml. See this for more details.




回答2:


For one, you may consider setting it in your php.ini. If you're on a shared server, that's not a viable option, but the common place to set project-global properties is the config/ProjectConfiguration.php, just after plugin setup.



来源:https://stackoverflow.com/questions/8777191/set-the-default-timezone-in-symfony

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!