# Strange to\_formatted\_s problem

**URL:** <https://www.ruby-forum.com/t/strange-to-formatted-s-problem/176784>\
**Category:** Rails\
**Created:** [October 6, 2009, 7:06am UTC](https://www.ruby-forum.com/t/strange-to-formatted-s-problem/176784 "2009-10-06T07:06:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![boblu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/b19c9b/32.png) [@boblu](https://www.ruby-forum.com/u/boblu)\
**Post date:** [October 6, 2009, 7:06am UTC](https://www.ruby-forum.com/t/strange-to-formatted-s-problem/176784/1 "2009-10-06T07:06:58Z")

</div>

my time zone is set like this

config.time\_zone = ‘Tokyo’

I got this from console

> > temp1.updated\_at  
> > =\> Tue, 06 Oct 2009 13:26:57 JST +09:00
> 
> > temp1.updated\_at.to\_formatted\_s(:db)  
> > =\> “2009-10-06 04:26:57”
> 
> > temp1.updated\_at.to\_formatted\_s(:long)  
> > =\> “October 06, 2009 13:26”

Can anyone tell me why I get different results when using :db  
and :long in to\_formatted\_s?

---

<div class="post-metadata">

**Author:** ![boblu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/b19c9b/32.png) [@boblu](https://www.ruby-forum.com/u/boblu)\
**Post date:** [October 6, 2009, 9:58am UTC](https://www.ruby-forum.com/t/strange-to-formatted-s-problem/176784/2 "2009-10-06T09:58:31Z")

</div>

On Oct 6, 6:05 am, boblu [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> =\> “2009-10-06 04:26:57”\>\> temp1.updated\_at.to\_formatted\_s(:long)
> 
> =\> “October 06, 2009 13:26”
> 
> Can anyone tell me why I get different results when using :db  
> and :long in to\_formatted\_s?

Why would you expect them to be the same ?

Fred

---

<div class="post-metadata">

**Author:** ![boblu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/b19c9b/32.png) [@boblu](https://www.ruby-forum.com/u/boblu)\
**Post date:** [October 6, 2009, 10:02am UTC](https://www.ruby-forum.com/t/strange-to-formatted-s-problem/176784/3 "2009-10-06T10:02:02Z")

</div>

On Oct 6, 8:57 am, Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> 

Oops, hadn’t noticed that the time of day was different by 9 hours.  
This is almost certainly because ActiveRecord wants to keep things in  
the database in UTC.

Fred
