Different values for Time.now when using activerecord
Posted
by
Josué Lima
on Stack Overflow
See other posts from Stack Overflow
or by Josué Lima
Published on 2014-06-06T02:47:52Z
Indexed on
2014/06/06
3:24 UTC
Read the original article
Hit count: 172
I have this weird situation:
When I do on rails console Time.now
or Time.zone.now
I get the same values (suppose they run at the sime time: 2014-06-05 23:38:06 -0300
)
But when I use Time.now in a query like: Match.where("datetime = ?", Time.now)
it returns the time 3 hours ahead!
.to_sql output:
SELECT `matches`.* FROM `matches` WHERE (datetime = '2014-06-06 02:38:06')
any thoughts on that?
- Rails 4
- Mysql 5.5
© Stack Overflow or respective owner