我使用的是默认时区-06:00(美国)的共享服务器,但网站中的所有用户都在+03:00时区。 我可以通过仅使用php来更改显示给用户的时间,因为无法修改服务器设置。 我搜索了很多,尝试使用的.htaccess使用此代码使用php更改时区
SetEnv TZ America/Indianapolis
设置时区,也是我在PHP代码
putenv("TZ=Asia/Baghdad");
date_default_timezone_set("Asia/Baghdad");
的开头添加了这个代码,但仍然没有改变
这是我的显示日期和时间:
echo date('Y-m-d/h:i a', strtotime($articles_info['date']));
这可能是一个简单的解决方案,但我仍然在学习过程中。 非常感谢..
为什么不通过时区,当你'strtotime()'日期? – Darren
我在php手册中没有找到像这样的方式,你可以帮助使用语法@Darren –
可靠的事情,'$ articles_info ['date']'看起来像什么?你可以尝试如下:'strtotime($ articles_info ['date']。'+0300');' – Darren