0

I am using Rhoconnect for synchronizing Rails and Rhodes app. The db structure includes a datetime field along with others. when i display these records on rhodes app, the date time field (created_at) is showing '1330520025' instead of date and time. How can i convert this to show actual date and time.

Douglas Lise
  • 1,466
  • 1
  • 20
  • 46
Priya Saini
  • 109
  • 13

1 Answers1

0

You could use the Ruby Time.strptime funcion, that is used to parse a time string. You must pass the format as the second argument. In this case the format is '%s':

s_time = '1330520025'
require 'time'
t = Time.strptime s_time, '%s'

You can format it using this function:

t.strftime('%d/%m/%Y %I:%M:%S %p')    

More details on format masks you could see in this site: http://snippets.dzone.com/posts/show/2255

Douglas Lise
  • 1,466
  • 1
  • 20
  • 46