I am having a strange issue with Time.now.utc in my production environment. The development environment is giving the correct values. I am using ruby-2.1.2-p95 and rails 4.0.0 for both the environments. The environments of my production and development are similar with no changes in the Time class.
Production Environment:
2.1.2 :001 > Time.now
=> 2016-05-20 18:16:24 +0200
2.1.2 :002 > Time.now.zone
=> "CEST"
Development Environment:
2.1.2 :012 > Time.now
=> 2016-05-20 16:16:24 +0200
2.1.2 :013 > Time.now.zone
=> "CEST"
As you can see from above, the time zones are same but the times in these different environments are different. Can anyone please point out where the error might be coming from? If you need further information please let me know.
Had a similar issue so as rails best practices suggested , Used
Time.zone.nowinstead ofTime.nowhttp://rails-bestpractices.com/posts/2014/10/22/use-time-zone-now-instead-of-time-now/
I hope it fixes for you too