How to setup timezone xampp mysql and apache?

后端 未结 4 890
没有蜡笔的小新
没有蜡笔的小新 2021-01-01 04:32

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         


        
4条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-01 04:51

    MySQL stores datetime as [yyyy-mm-dd hh:mm:ss] at the UTC timezone. Your field in the db may be set up incorrectly but it may help if you post it's parameters. You shouldn't need to change settings in the conf or php.ini files. I suspect the difference between UTC and your timezone is making the query fail at certain times of the day because the UTC timestamp has passed into the next day. You may need to compensate your date prior to making the query by adding (or subtracting) the right amount of time so the datetime matches UTC. Something like this: getRates(date("Y-m-d h:i:sa",(yourtimestamp + (7 * 60 * 60)))); Or declare the timezone prior to the query: date_default_timezone_set("America/New_York");

提交回复
热议问题