📜  symfony 设置时区 - 任何代码示例

📅  最后修改于: 2022-03-11 14:58:12.742000             🧑  作者: Mango

代码示例1
If you can’t set it in php.ini, or you want to be sure the value is consistent independently of the target environment, the easiest way is to set it in your AppBundle:

class AppBundle extends Bundle
{
    public function boot()
    {
        parent::boot();
        date_default_timezone_set("Europe/Madrid");
    }
}
Alternatively, if you don’t have an AppBundle (or any other own bundle), you could add it to the AppKernel::registerBundles() method, right before the bundles are loaded.