This project is archived and is in readonly mode.

#6654 ✓duplicate
Robert Pankowecki

Date.yesterday and Date.tomorrow returns wrong values

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

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...

Comments and changes to this ticket

  • Andrew White

    Andrew White March 30th, 2011 @ 09:40 PM

    • 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>

Pages