# time\_ago\_in\_words is off by a day

**URL:** <https://discuss.rubyonrails.org/t/time-ago-in-words-is-off-by-a-day/35257>\
**Category:** rubyonrails-talk\
**Created:** [October 11, 2008, 2:43am UTC](https://discuss.rubyonrails.org/t/time-ago-in-words-is-off-by-a-day/35257 "2008-10-11T02:43:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Wayne\_M](https://avatars.discourse-cdn.com/v4/letter/w/a698b9/32.png) [@Wayne\_M](https://discuss.rubyonrails.org/u/Wayne_M)\
**Post date:** [October 11, 2008, 2:43am UTC](https://discuss.rubyonrails.org/t/time-ago-in-words-is-off-by-a-day/35257/1 "2008-10-11T02:43:18Z")

</div>

Maybe someone can help me; I'm sure I'm just missing something silly. I have a Task model that has a due\_date. In my migration it's set to a date:

t.date :due\_date

I want to display both the actual date and a friendly format in the application, so in my view I have:

\<p\>\<%= time\_ago\_in\_words(@task.due\_date) %\> (\<%= @task.due\_date.to\_s(:long) %\>)\</p\>

I have a sample task that has a due date set to October 12th, and @task.due\_date.to\_s(:long) confirms this. However, time\_ago\_in\_words says that it's "1 day", when today is the 10th and it should be 2 days. In fact, I brought up a console and typed in 1.day.from\_now, and sure enough it says that tomorrow is Sunday the 12th, instead of Saturday the 11th.

What am I missing? Should I be using a datetime instead (presumably it has something to do with the accuracy), even though I don't care about the time, only the actual date?

If it matters at all, I am using Postgres as my database.

Thanks for any help.

- Wayne

---

<div class="post-metadata">

**Author:** ![Mauricio\_Linhares1](https://avatars.discourse-cdn.com/v4/letter/m/eada6e/32.png) [@Mauricio\_Linhares1](https://discuss.rubyonrails.org/u/Mauricio_Linhares1)\
**Post date:** [October 11, 2008, 2:49am UTC](https://discuss.rubyonrails.org/t/time-ago-in-words-is-off-by-a-day/35257/2 "2008-10-11T02:49:58Z")

</div>

Look at your 1.day.from\_now and see if it's like this:

Sun, 12 Oct 2008 02:45:42 UTC +00:00

If you also have the "UTC +00:00", it means that you timezone is the GMT (and I think that it isn't your real timezone). For example, my timezone is 3 hours after the GMT, so the right timezone would be something like this:

Sat Oct 11 23:48:41 -0300 2008

At your environment.rb file, look for something like this:

config.time\_zone = 'UTC'

And change it to your timezone.

---

<div class="post-metadata">

**Author:** ![Wayne\_M](https://avatars.discourse-cdn.com/v4/letter/w/a698b9/32.png) [@Wayne\_M](https://discuss.rubyonrails.org/u/Wayne_M)\
**Post date:** [October 11, 2008, 3:07am UTC](https://discuss.rubyonrails.org/t/time-ago-in-words-is-off-by-a-day/35257/3 "2008-10-11T03:07:50Z")

</div>

Yep, that was it. I knew it was something easy that I just overlooked.

Thanks a lot!
