brad
brad

Reputation: 1695

Date.tomorrow referencing two days from now

I'm seeing something very odd.

<h3><%= (Date.today).strftime("%A, %B %d, %Y")  %></h3>

is resulting in Wednesday, October 09, 2013 which is correct.

However, this results in Friday, October 11, 2013.

<h3><%= (Date.tomorrow).strftime("%A, %B %d, %Y")  %></h3>

It completely skips Thursday (which is truly tomorrow).

Any ideas?

Upvotes: 5

Views: 2070

Answers (2)

Steve Kass
Steve Kass

Reputation: 7184

The method tomorrow isn't in Ruby - only in Rails. Maybe your Ruby and your Rails are set for different timezones. What do you get from Date.current, which is basically today in rails?

Upvotes: 5

Sachin
Sachin

Reputation: 1003

Rails-Date has provided current method to compliment today method of Ruby-Date. So now you can use:

Date.current     # Rails equivalent of Ruby's - Date.today
Date.tomorrow

for all dates which should be respecting Rails timezone and Ruby-Date.today keeps being what it is.

Upvotes: 2

Related Questions