0

So guys, I have a problem with time in my system

If I print this directly in my database(Mariadb using phpmyadmin) or directly in the server the time is correct..

mysql > SELECT now();

and when I print this directly in the file(.php)

echo date("Y-m-d H:i:s");

but, if I print this...

echo $conn->query('SELECT NOW()')->fetchColumn(0);

the time shows with an hour more.

Can someone help me? What am I missing here?

  • Yes, I am aware about date_default_timezone_set(), the time still shows wrong. @Luuk I edited my question – Lucas Galli Oct 20 '20 at 13:08
  • You have to do some testing/debugging, maybe this can help: https://stackoverflow.com/questions/48774010/time-difference-between-php-and-mysql – Luuk Oct 20 '20 at 16:02
  • Thanks for helping me @Luuk , this solution seems a little trick to fixed, but I can't synchronized my PHP and MySQL timezones this way, because I am using multiple timezones. – Lucas Galli Oct 20 '20 at 17:15
  • make 1 testscript whit output from PHP-datetime and the times you are getting from MySQL (+timezone). Also add the relevant values from settings to the testscript. Change settings, Evaluate testscript output, and start over... (until a solution is found...). . – Luuk Oct 20 '20 at 18:43

0 Answers0