如何设置时区 xampp mysql 和 apache?

2022-01-14 00:00:00 datetime xampp php mysql

我正在使用 XAMPP - PHP 和 MYSQL 服务器.当我尝试使用以下 -

I am using XAMPP - PHP and MYSQL servers. When I tried to use following -

getRates(date('Y-m-d'));



function getRates($cDate)
{
$query = "SELECT * FROM randa WHERE date like '$cDate'" //it only worked at times.  
}

?>

然后我意识到 date('Y-m-d') 没有返回正确的日期.转到 php.ini 并更改时区.并且仍然返回错误的日期.

Then I realized the date('Y-m-d') does not return the correct date. Went to php.ini and changed time zone. And is still returning the wrong date.

我该如何解决这个问题?谢谢你

How can I fix this ? Thank you

推荐答案

试试这个

1) 在 httpd.conf (xamppapacheconfhttpd.conf) 中,添加以下行:

1) In httpd.conf (xamppapacheconfhttpd.conf) , add the following line:

SetEnv TZ Europe/Moscow

2) 在 [Date] 部分编辑 php.ini (xamppphpphp.ini) date.timezone 值:

2) Edit php.ini (xamppphpphp.ini) date.timezone value in [Date] section:

date.timezone = "Europe/Moscow"

3) 在 my.ini (xamppmysqlinmy.ini) 中添加或替换

3) In my.ini (xamppmysqlinmy.ini) add or replace

default-time-zone = "Europe/Moscow"

重启 Apache 和 MySQL

Restart Apache and MySQL

相关文章