mentalic
mentalic

Reputation: 57

Rails - Don't want timezone in sql o/p

I have a Rails app on PGSQL and there is a Date of Birth column (timestamp without time zone).

I use a "select" to get the employee data back and return that as JSON, but the DOB always comes back with a timezone, e.g. "dob":"1992-06-18T20:00:00-04:00".

I tried using to_char(emp.dob, 'YYYY-MM-DD HH24:MI:SS'), but no effect.

Any one has any ideas how to get the o/p to not contain TZ information?

Something like: 1992-06-18 20:00:00

Thanks

EDIT: Found the solution to a similar question here: rails dates with json

Upvotes: 0

Views: 82

Answers (1)

hrr
hrr

Reputation: 1651

Use the localization method and type the following:

<%= l emp.dob, :format => :long %>

There are several pre-defined options to show the text (:long, :short etc) You can read more here.

Upvotes: 0

Related Questions