2

Here's my output in console:

mysql> select CURRENT_TIMESTAMP;
+---------------------+
| CURRENT_TIMESTAMP   |
+---------------------+
| 2012-04-14 16:35:57 |
+---------------------+
1 row in set (0.00 sec)

mysql> exit
Bye
VNMB:qhuen VictorNg$ rails c
Loading development environment (Rails 3.1.1)
1.8.7 :001 > Time.now
 => Sat Apr 14 16:36:28 +0800 2012 
1.8.7 :002 > Time.zone.now
 => Sat, 14 Apr 2012 16:36:31 MYT +08:00 
1.8.7 :003 > 

and in my application.rb it is set:

config.time_zone = 'Kuala Lumpur'

But when my rails model is touched, the updated_at column shows:

2012-04-14 08:36:21

What else do I need to do to correct this?

Thanks.

Victor
  • 13,010
  • 18
  • 83
  • 146

1 Answers1

3

You might be misunderstanding what time formats Rails uses in various places. A question I've answered in the past might help:

Why doesn't `config.time_zone` seem to do anything?

If you want your local timezone used in the actual database records you can set config.active_record.default_timezone = :local in your application.rb (assuming Rails3)

Community
  • 1
  • 1
Chris Cherry
  • 28,118
  • 6
  • 68
  • 71
  • Thanks. It's clearer now. How do I set back to the timestamp that I wanted? – Victor Apr 14 '12 at 08:49
  • 2
    If you want your local timezone used in the actual database records you can set `config.active_record.default_timezone = :local` in your `application.rb` (assuming Rails3) – Chris Cherry Apr 14 '12 at 08:53
  • Works like charm. Would you mind to include that in your answer, so that I can mark it as answer? Many thanks. – Victor Apr 14 '12 at 08:59