# Difference in time between Rails and Mysql timestamps

**URL:** <https://www.ruby-forum.com/t/difference-in-time-between-rails-and-mysql-timestamps/166252>\
**Category:** Rails\
**Created:** [April 23, 2009, 8:17am UTC](https://www.ruby-forum.com/t/difference-in-time-between-rails-and-mysql-timestamps/166252 "2009-04-23T08:17:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tkbeili](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/7bcc69/32.png) [@tkbeili](https://www.ruby-forum.com/u/tkbeili)\
**Post date:** [April 23, 2009, 8:17am UTC](https://www.ruby-forum.com/t/difference-in-time-between-rails-and-mysql-timestamps/166252/1 "2009-04-23T08:17:31Z")

</div>

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
