Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Date.yesterday and Date.tomorrow returns wrong values

#6654
ruby-1.9.2-p136 :004 > Time.now
 => 2011-03-30 01:15:20 +0200
ruby-1.9.2-p136 :005 > Date.today
 => Wed, 30 Mar 2011
ruby-1.9.2-p136 :006 > Date.yesterday
 => Mon, 28 Mar 2011
ruby-1.9.2-p136 :007 > Time.zone
 => (GMT+00:00) UTC
ruby-1.9.2-p136 :008 > Date.tomorrow
 => Wed, 30 Mar 2011

Affected versions : 3.0.4, 3.0.5, 3.0.6.rc1 maybe more...

Reported by Robert Pankowecki · March 30th, 2011 @ 07:33 PM

State: duplicate
Milestone: none
Assigned to: nobody
Importance: Low

Activity

  1. Andrew White
    Andrew White
    • State changed from new to duplicate
    • Importance changed from to Low

    This is a duplicate of #6410 Date.yesterday == Date.today - 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.

    March 30th, 2011 @ 09:40 PM