Josh Hallow
Josh Hallow

Reputation: 349

MySQL now() is 1 hour behind

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.

Upvotes: 2

Views: 2570

Answers (2)

trex005
trex005

Reputation: 5115

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';

Upvotes: 2

nathanmac
nathanmac

Reputation: 455

mysql> SET GLOBAL time_zone = 'America/New_York';

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

Upvotes: 0

Related Questions