# Problem with Time Zone Rails 2.3.2

**URL:** <https://www.ruby-forum.com/t/problem-with-time-zone-rails-2-3-2/167185>\
**Category:** Rails\
**Created:** [May 5, 2009, 7:40am UTC](https://www.ruby-forum.com/t/problem-with-time-zone-rails-2-3-2/167185 "2009-05-05T07:40:57Z")\
**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:** [May 5, 2009, 7:40am UTC](https://www.ruby-forum.com/t/problem-with-time-zone-rails-2-3-2/167185/1 "2009-05-05T07:40:57Z")

</div>

Hello,

I’m using Rail 2.3.2 and I want to include time zones with my  
application by putting:  
config.time\_zone = “Pacific Time (US & Canada)”

in my environment.rb.

This works fine on my Mac development machine but I move to production  
it gets messed up…For instance I have a condition as follows:  
:conditions =\> [’(effective\_end\_date IS NULL OR effective\_end\_date \> ?)  
AND (effective\_start\_date IS NULL OR  
effective\_start\_date \< ?) ',Time.now.gmtime, Time.now.gmtime]

Which works fine on development as mentioned earlier by looking at  
queries but on production I got something like this

SELECT \* FROM `sms_messages` WHERE (`sms_messages`.user\_id = 1 AND  
(created\_at \> ‘2009-04-05 05:18:23’ and status != ‘SCHEDULED\_MESSAGE’))  
AND (((effective\_end\_date IS NULL OR effect  
ive\_end\_date \> ‘2009-05-03 03:19:57’)  
AND (effective\_start\_date IS NULL OR effective\_start\_date \< ‘2009-05-03  
03:19:57’) ) AND (`sms_messages`.user\_id = 1)) ORDER BY created\_at DESC

But when I try to fetch time form IRB:

> > Time.now  
> > =\> Mon May 04 22:24:27 -0700 2009
> 
> > Time.now.gmtime  
> > =\> Tue May 05 05:24:34 UTC 2009

Which seems correct!!! It’s like as if instead of adding 7 hours to get  
the UTC time it negates 7 hours from the current time!

Not sure if I have to do extra setting for production machine.

Any ideas how to go about finding what the problem is?

Thanks,

Tam
