php date_default_timezone_set("Europe/London") 没有返回正确的时间

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6201716/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 23:38:40  来源:igfitidea点击:

date_default_timezone_set("Europe/London") does not return correct time

phptimezonedefault-valuedate-format

提问by user739393

When I use following code to get current London time, it gives the wrong time.

当我使用以下代码获取当前伦敦时间时,它给出了错误的时间。

At the time of testing the current London time was 02:11:16 PM, Wednesday 01, June 2011, but I using the following code:

在测试时,当前伦敦时间是2011 年 6 月 1 日星期三下午 02:11:16,但我使用以下代码:

date_default_timezone_set('Europe/London');
echo date('m/d/y h:i a', time());

Gave me: 06/02/11 02:12 am

给了我:06/02/11 02:12 am

Why did it not return correct London time?

为什么它没有返回正确的伦敦时间?

回答by Michal - wereda-net

date_default_timezone_set("Europe/London");

try with double quotes. works on godaddy

用双引号试试。在godaddy上工作

回答by Arun Kumar

Check your ini file whether timezone is set or not,

检查您的ini文件是否设置了时区,

ini_set('date.timezone', 'Europe/London');

Try this it should work.

试试这个它应该工作。