2

I am trying to get all the votes from TODAY THE CURRENT , and I have almost achieved that with the following mysql query, but there's one problem.

This code gets me the votes from today:

SELECT COUNT(*) FROM votes WHERE `when` > CURRENT_DATE

but when inserting into mysql using now() the now() is 1 hour behind my timezone (Europe/London) how can I fix that?

Thanks.

Josh Hallow
  • 359
  • 3
  • 15

2 Answers2

2

You will need to populate your timezone tables. If you are on linux, you can do so by running the following command :

mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root mysql

You may need to know your root password. You then can run the following query as root :

SET GLOBAL time_zone = 'Europe/London';
trex005
  • 5,015
  • 4
  • 28
  • 41
  • That is why you need to populate your timezone tables. Did you do that step? – trex005 Aug 22 '15 at 01:59
  • 1
    Didn't work for me, after setting ``time_zone`` to "Europe/Berlin", ``NOW()`` is still 1 hour behind. Edit: Nevermind, the timezone in the docker container running MySQL was also incorrect. – Philipp Ludwig Mar 23 '18 at 10:43
0
mysql> SET GLOBAL time_zone = 'America/New_York';

https://dev.mysql.com/doc/refman/5.5/en/time-zone-support.html

nathanmac
  • 455
  • 1
  • 6
  • 14