views:

21

answers:

1

In my database on heroku, it shows contactemail.created_at = "2010-08-08 17:16:19"

However, when I use puts.contactemail.created_at I get something different. I get:

2010-08-08 10:11:13 -0700

I need to input that value through an API to another application, and I am pretty sure that the first format is what it wants. If it doesn't take that, it wants 08/08/10 17:16:19 -- in either case, I don't know how to format it properly.

This is in Ruby on Rails.

A: 

The display of date is based on your servers locale settings. If you are looking for the first format you could try

puts.contactemail.created_at.to_s(:db)

Have a look at strftime doc here http://ruby-doc.org/core/classes/Time.html#M000298 to get the second format

HTH

Anand