PHP 默认时区 [英] PHP default timezone

查看:22
本文介绍了PHP 默认时区的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

php中有一个设置默认时区的功能-

there is a function in php to set default timezone-

date_default_timezone_set('Asia/Calcutta');

但是每当我想使用日期时,每次在应用程序中都需要调用它吗?

but does this need to be called every time in the application, whenever I want to make use of date?

推荐答案

但是每次在应用程序中,每当我想使用日期时都需要调用它吗?

but does this need to be called every time in the application, whenever I want to make use of date?

如果您的应用程序需要不同的时区 php.ini,那么是的,您需要在脚本中调用 date_default_timezone_set.如果 php.ini 中没有配置时区,你也需要调用它,但如果是这种情况,你需要纠缠你的主机来修复它.

If your application needs a different timezone than configured in php.ini, then yes, you need to call date_default_timezone_set in your script. You will also need to call it if there is no timezone configured in php.ini, though if that is the case, you need to pester your host to fix it.

这篇关于PHP 默认时区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆