views:

134

answers:

2

Hi all,

I'm creating a new Rails 3 app, and in it I use datetime for a couple of fields,

however every datetime field standard has UTC behind it (in a view), like:

2010-10-10 16:19:00 UTC

How do I get rid of the UTC part?

UPDATE: here's what I have so far:

<%= trip.truckleft.strftime("%Y-%m-%d %H:%M") %>

So all I have to do now is put that in a helper.. but isn't there a better more universal way?

I looked at some other posts, that suggested creating a time_formats.rb in initializers, however I didn't have any success doing that.

Thanks for your help, much appreciated!

A: 

You can put the following line at the end of your config/environment.rb file:

Date::DATE_FORMATS[:default] = "%Y-%m-%d %H:%M"
floatless
unfortunately that didn't work
Paintrick
A: 

Here is what finally worked for me:

I created a new file in:

config/initializers/

named: time_formats.rb

and added this to that file: Time::DATE_FORMATS[:default] = "%Y-%m-%d %H:%M"

Then I saved and it worked.

Paintrick