Alex Rivera | Logout

Format the date using Ruby on Rails

Asked 2012-06-18T20:20:57.893
81

The flickr api provides a posted date as unix timestamp one: "The posted date is always passed around as a unix timestamp, which is an unsigned integer specifying the number of seconds since Jan 1st 1970 GMT."

For example, here is the date '1100897479'. How do I format it using Ruby on Rails?

Edit
Report

1 Answer

28

Easiest is to use strftime (docs).

If it's for use on the view side, better to wrap it in a helper, though.

answered 2012-06-18T20:24:46.690

Your Answer