PHP date_default_timezone_set() [英] PHP date_default_timezone_set()

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

问题描述

在 php 中,有没有办法在 .htaccess 或任何地方设置默认时区,只要我不必在每个 php 页面设置它.

In php, is there a way to set default timezone in .htaccess or wherever, as long as i don have to set it at every php page.

前提是我无权访问服务器,只能访问 PHP 文件.提前致谢

provided i don have access to server, only PHP files. Thanks in advance

更新

我正在使用 apache (LAMP),但无法访问 php.ini

i am using apache (LAMP), and don't have access to php.ini

推荐答案

从您提到 .htaccess 的事实考虑您使用 apache:

Considering you use apache from the fact you mention .htaccess:

是的,只要它运行 mod_php 就可以在 .htaccess 中像这样:

Yes, as long as it runs mod_php it is possible in .htaccess like so:

php_value date.timezone "Europe/Berlin"

或者你可以像 Karl Laurentius Roos 建议的那样在 php.ini 中设置 date.timezone.这只有在您可以通过访问您的 php 配置时才有可能.修改 php.ini 后记得重启 PHP(CGI 模式)或 web 服务器(mod_php).

Or you could set date.timezone in php.ini like Karl Laurentius Roos suggested. This would only be possible if you have access to your php config through. Remember to restart PHP (CGI mode) or your webserver (mod_php) after altering php.ini.

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

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