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

**URL:** <https://www.ruby-forum.com/t/time-ago-in-words-is-off-by-a-day/150669>\
**Category:** Rails\
**Created:** [October 11, 2008, 4:43am UTC](https://www.ruby-forum.com/t/time-ago-in-words-is-off-by-a-day/150669 "2008-10-11T04:43:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![wemagor](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/8edcca/32.png) [@wemagor](https://www.ruby-forum.com/u/wemagor)\
**Post date:** [October 11, 2008, 4:43am UTC](https://www.ruby-forum.com/t/time-ago-in-words-is-off-by-a-day/150669/1 "2008-10-11T04:43:47Z")

</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:

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

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:** ![wemagor](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/8edcca/32.png) [@wemagor](https://www.ruby-forum.com/u/wemagor)\
**Post date:** [October 11, 2008, 4:50am UTC](https://www.ruby-forum.com/t/time-ago-in-words-is-off-by-a-day/150669/2 "2008-10-11T04:50:48Z")

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

On Fri, Oct 10, 2008 at 11:43 PM, Wayne M [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> \<%= time\_ago\_in\_words(@task.due\_date) %\> (\<%= 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
> 
> >

–  
Maurício Linhares  
[http://alinhavado.wordpress.com/](http://alinhavado.wordpress.com/) (pt-br) | [http://blog.codevader.com/](http://blog.codevader.com/)  
(en)  
João Pessoa, PB, +55 83 8867-7208

---

<div class="post-metadata">

**Author:** ![wemagor](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/8edcca/32.png) [@wemagor](https://www.ruby-forum.com/u/wemagor)\
**Post date:** [October 11, 2008, 5:08am UTC](https://www.ruby-forum.com/t/time-ago-in-words-is-off-by-a-day/150669/3 "2008-10-11T05:08:20Z")

</div>

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

Thanks a lot!

On Oct 10, 10:49 pm, “Maurício Linhares” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
