XAMPP PHP 日期函数时间与本地机器时间不同
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15359451/
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
XAMPP PHP date function time is different from local machine time
提问by Raja
My computer local time is 12-03-2013 4:30pm.
我的电脑当地时间是12-03-2013 4:30pm。
My XAMPP date function prints the time as 12-03-2013 10:49:56.
我的 XAMPP 日期函数将时间打印为12-03-2013 10:49:56.
How can I set the XAMPP server time to display the system time?
如何设置 XAMPP 服务器时间以显示系统时间?
回答by Damonsson
Go to C:\xampp\php\php.ini, or your custom path where php.iniis, open it.
转到C:\xampp\php\php.ini,或您的自定义路径在哪里php.ini,打开它。
Look for the following: date.timezone = "Europe/Warsaw". Probably You have different value than my Europe/Warsaw. So search just string: date.timezone.
查找以下内容:date.timezone = "Europe/Warsaw". 可能你的价值与我的不同Europe/Warsaw。所以只搜索 string: date.timezone。
Change value Europe/Warsawto the proper value, for example date.timezone = "Asia/Kolkata"
将值更改Europe/Warsaw为适当的值,例如date.timezone = "Asia/Kolkata"
If someone's looking for his location, check valid values http://php.net/manual/en/timezones.php
如果有人正在寻找他的位置,请检查有效值http://php.net/manual/en/timezones.php
Don't forget to restart your XAMPP.
不要忘记重新启动您的 XAMPP。
回答by niq
For others who are confused on what timezone (date.timezone) they should use (just like me a while ago), please refer to this manual from PHP
对于其他对应该使用哪个时区(date.timezone)感到困惑的人(就像我之前一样),请参阅 PHP 中的本手册
http://php.net/manual/en/timezones.php
http://php.net/manual/en/timezones.php
Hope this helps.
希望这可以帮助。
回答by PutihTua
At your XAMPP you can change the php.ini and search
在您的 XAMPP,您可以更改 php.ini 并搜索
date.timezone
and change it to your prefer timezone
并将其更改为您喜欢的时区
date.timezone = Asia/Jakarta
That's for XAMPP. And if you can't change the web server time at your remote server, try put this date_default_timezone_set() function at your php. Like this :
那是为了 XAMPP。如果您无法更改远程服务器上的 Web 服务器时间,请尝试将此 date_default_timezone_set() 函数放在您的 php.ini 中。像这样 :
<?php date_default_timezone_set('Asia/Jakarta'); ?>

