在symfony中设置默认时区 [英] Set the default timezone in symfony
问题描述
我想知道如何为整个项目设置时区?
我使用symfony 1.4与doctrine,我有一个日期时间保存的问题。
每当我保存一个记录,这是时间不正确我知道这是因为时区。
我知道我可以使用 date_default_timezone_set()
函数设置默认时区,但是我必须在每个我使用日期的单一动作,这是不正确的。有没有更简单的方法呢?
我认为教义应该有自动设置,但我不知道如何。
symfony的方法是使用 default_timezone
in settings.yml 。有关详细信息,请参阅此。
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.
The symfony way is to use default_timezone
in settings.yml. See this for more details.
这篇关于在symfony中设置默认时区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!