# Wrong time in application

**URL:** <https://www.ruby-forum.com/t/wrong-time-in-application/205723>\
**Category:** Rails\
**Created:** [April 14, 2011, 9:05am UTC](https://www.ruby-forum.com/t/wrong-time-in-application/205723 "2011-04-14T09:05:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [April 14, 2011, 9:05am UTC](https://www.ruby-forum.com/t/wrong-time-in-application/205723/1 "2011-04-14T09:05:29Z")

</div>

hey guys,

i’ve got a problem and i really don’t know how to solve it.  
when i’m creating a new dataset in my application, the created\_at and  
updated\_at time will be saved in UTF Time (+000).  
in my environment.rb i set the following line:  
config.time\_zone = ‘Berlin’  
when i’m using the console (script/console) for reading out some example  
dataset, the created\_at and updated\_at timestamp will be shown like  
this:

Thu, 14 Apr 2011 08:27:04 CEST +02:00

this is correct, because you have to add 2 hours to get the time in  
berlin.  
but if i read out the datasets in my application and show them in the  
views, no hours will be added to the UTF Times saved in the database.

i don’t know why it works in the console but not while executing the  
application.

please help me!

Tobias

---

<div class="post-metadata">

**Author:** ![machinetobe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ecd19e/32.png) [@machinetobe](https://www.ruby-forum.com/u/machinetobe)\
**Post date:** [April 14, 2011, 10:07am UTC](https://www.ruby-forum.com/t/wrong-time-in-application/205723/2 "2011-04-14T10:07:13Z")

</div>

On Apr 14, 8:05am, “Tobias H.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Thu, 14 Apr 2011 08:27:04 CEST +02:00
> 
> this is correct, because you have to add 2 hours to get the time in  
> berlin.  
> but if i read out the datasets in my application and show them in the  
> views, no hours will be added to the UTF Times saved in the database.

How are you displaying them?

Fred

---

<div class="post-metadata">

**Author:** ![machinetobe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ecd19e/32.png) [@machinetobe](https://www.ruby-forum.com/u/machinetobe)\
**Post date:** [April 14, 2011, 10:13am UTC](https://www.ruby-forum.com/t/wrong-time-in-application/205723/3 "2011-04-14T10:13:08Z")

</div>

> How are you displaying them?
> 
> Fred

in the view with:  
\<%= l @execution.created\_at %\>

the l means in this case, that i format the date in german notation.

greetz, tobias

---

<div class="post-metadata">

**Author:** ![machinetobe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ecd19e/32.png) [@machinetobe](https://www.ruby-forum.com/u/machinetobe)\
**Post date:** [April 14, 2011, 11:26am UTC](https://www.ruby-forum.com/t/wrong-time-in-application/205723/4 "2011-04-14T11:26:19Z")

</div>

Try adding this to environment.rb

config.active\_record.default\_timezone = :local

2011/4/14 Tobias H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![machinetobe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ecd19e/32.png) [@machinetobe](https://www.ruby-forum.com/u/machinetobe)\
**Post date:** [April 14, 2011, 11:44am UTC](https://www.ruby-forum.com/t/wrong-time-in-application/205723/5 "2011-04-14T11:44:52Z")

</div>

On Apr 14, 9:13am, “Tobias H.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > How are you displaying them?
> 
> > Fred
> 
> in the view with:  
> \<%= l @execution.created\_at %\>
> 
> the l means in this case, that i format the date in german notation.

Dumb question: did you restart the server after setting  
config.time\_zone ?

Fred
