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
Please add this code on your top page.
date_default_timezone_set('America/Los_Angeles');
Search your country here http://php.net/manual/en/timezones.php
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");
Try this
1) In httpd.conf (\xampp\apache\conf\httpd.conf) , add the following line:
SetEnv TZ Europe/Moscow
2) Edit php.ini (\xampp\php\php.ini) date.timezone value in [Date] section:
date.timezone = "Europe/Moscow"
3) In my.ini (\xampp\mysql\bin\my.ini) add or replace
default-time-zone = "Europe/Moscow"
Restart Apache and MySQL
Solved: but feeling stupid.
my local machine had the correct time however, time zone was incorrect. Changed the time zone and it worked. I don't understand why though. The time WAS CORRECT. Zone was not.