This project is archived and is in readonly mode.
Date.yesterday on Rails3 return two days back date till 5:30 a.m., after that it returns last day
Reported by Ritesh Kumar | March 3rd, 2011 @ 09:20 AM
Date.yesterday on Rails3 return two days back date till 5:30 a.m. after that it returns last day. Whereas on Rails 2.3.5 the same scenario is working fine.
Rails 3 application returning two days back date till 5:30 a.m
C:\projects\rails3demo>rails c
Loading development environment (Rails 3.0.3)
irb(main):002:0> DateTime.now
=> Thu, 03 Mar 2011 02:20:23 +0530
irb(main):003:0> Date.yesterday => Tue, 01 Mar 2011
irb(main):008:0> DateTime.now
=> Thu, 03 Mar 2011 14:39:35 +0530
irb(main):009:0> Date.yesterday
=> Wed, 02 Mar 2011
Rails 2.3.5 application returning last date
C:\projects\rails2demo>ruby script/console
Loading development environment (Rails 2.3.5)
DateTime.now => Thu, 03 Mar 2011 02:21:29 +0530
Date.yesterday => Wed, 02 Mar 2011
DateTime.now => Thu, 03 Mar 2011 14:39:17 +0530
Date.yesterday => Wed, 02 Mar 2011
Comments and changes to this ticket
-
Andrew White March 3rd, 2011 @ 11:05 AM
- State changed from new to duplicate
- Importance changed from to Low
This is a duplicate of #6410 - Time.now & Date.today use the local system time and Date.yesterday uses Time.zone which defaults to UTC in Rails. Use Date.current and Time.current to get the current time and date in your application.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>