Difference in time between Rails and Mysql timestamps

Hello,

I have on my database table column called effective_start_date which
tracks when the record should start to be active.

So if I want the record to be active instantly I say something like:

the_record.effective_start_date = Time.now.gmtime

and then I search for it instantly after with query condition like:

SELECT * FROM … (sms_clients.effective_start_date IS NULL OR
sms_clients.effective_start_date < Time.now.gmtime)

Which wouldn’t find the record!!!

After looking in DB I realized there is small difference with time
between one recorded in MySQL and the one generated by Rails query. I
have Debian VPS. It doesn’t happen when I design on my local Mac
machine.

I can get around the issue in different ways but I thought MySql and
Rails should use system time so they should be identical. Do you have
any idea why they might be different and how to make them same so I
don’t run in similar problems in future.

Thanks,

Tam