Forum: Ruby on Rails difference in time between Rails and Mysql timestamps

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Tam K. (Guest)
on 2009-04-23 10:17
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
This topic is locked and can not be replied to.