# Rails Time.now and system locale

**URL:** <https://www.ruby-forum.com/t/rails-time-now-and-system-locale/87737>\
**Category:** Rails\
**Created:** [March 5, 2007, 5:59pm UTC](https://www.ruby-forum.com/t/rails-time-now-and-system-locale/87737 "2007-03-05T17:59:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [March 5, 2007, 5:59pm UTC](https://www.ruby-forum.com/t/rails-time-now-and-system-locale/87737/1 "2007-03-05T17:59:15Z")

</div>

hi everyone, I have a problem with dates output.

Actually if in Rails’ ./script/console I send a “Time.now” I get a  
localized  
date, something like: “lun mar 05 19:33:00 CET 2007”  
Actually my server has environment variables set for Italy, here’s the  
output of the locale command:  
LANG=it\_IT@euro  
LC\_CTYPE=“it\_IT@euro”  
LC\_NUMERIC=“it\_IT@euro”  
LC\_TIME=“it\_IT@euro”  
LC\_COLLATE=“it\_IT@euro”  
LC\_MONETARY=“it\_IT@euro”  
LC\_MESSAGES=“it\_IT@euro”  
LC\_PAPER=“it\_IT@euro”  
LC\_NAME=“it\_IT@euro”  
LC\_ADDRESS=“it\_IT@euro”  
LC\_TELEPHONE=“it\_IT@euro”  
LC\_MEASUREMENT=“it\_IT@euro”  
LC\_IDENTIFICATION=“it\_IT@euro”  
LC\_ALL=

The strange thing is that the standard Ruby IRB doesn’t consider the  
environment locale, and sending “Time.now” i get the following output:  
irb(main):001:0\> Time.now  
=\> Mon Mar 05 19:37:04 CET 2007

So I can desume that Rails, instead, make use of the system locale  
automagically…

I defeinitely disagree with this behaviour, is there a way I can handle  
it  
to give me international output by default?

–  
Ashkey \< Jules Piccotti

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [June 16, 2008, 7:42pm UTC](https://www.ruby-forum.com/t/rails-time-now-and-system-locale/87737/2 "2008-06-16T19:42:32Z")

</div>

Ashkey wrote:

> Actually if in Rails’ ./script/console I send a “Time.now” I get a  
> localized  
> date, something like: “lun mar 05 19:33:00 CET 2007”  
> …

> The strange thing is that the standard Ruby IRB doesn’t consider the  
> environment locale, and sending “Time.now” i get the following output:  
> irb(main):001:0\> Time.now  
> =\> Mon Mar 05 19:37:04 CET 2007

It looks like you’ve answered your own question. In Rails you’ve  
overridden default behavior with localization settings. Thus, when you  
run console, you’re inheriting the localization. IRB does not load your  
Rails configuration. My guess is that your server settings are set for  
a different locale - which is what IRB is inheriting.
