且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

wamp服务器中错误的PHP日期()输出

更新时间:2023-02-19 18:30:22

我建议总是使用 date_default_timezone_set() 来自脚本

I suggest always using date_default_timezone_set() from script

例如

date_default_timezone_set('Europe/Kiev');

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

...避免 PHP 猜测时区.

...to avoid PHP guessing timezone.

当您将代码传输到不同的服务器(例如,乌克兰***)时,它会派上用场.如果 date.timezone 未在 php.ini 中设置或其设置不正确,此行将帮助您避免意外(错误)结果.当您无法访问和/或修改 php.ini(共享主机)时,它也很方便.

It comes handy when you transfer code to different server(s), for example, outside of Ukraine. This line should help you to avoid unexpected (wrong) results if date.timezone is not set in php.ini or its setting is incorrect. It's also handy when you can't access and/or modify php.ini (shared hosting).

另外,请确保您没有在 php.ini 中的和 of 行使用 ;.

Also, be sure that you've not used ; at the and of line in php.ini.

更改php.ini后重启服务器.