Topic: convert unix timestamp to date mysql understands

I'm trying to take a UNIX timestamp within a file and convert it to input that ruby and mysql understands YYYYMMDD).  Is there a quick way to do this?  I've seen a javascript solution, but would prefer something more native.  Looked at the date class and didn't see anything right off the bat - am I missing something easy?

Re: convert unix timestamp to date mysql understands

Try:

Time.at(timestamp)

Railscasts - Free Ruby on Rails Screencasts

Re: convert unix timestamp to date mysql understands

I then get the error message:
    in 'at': can't convert String into time (TypeError)


This is what I used (I'm parsing xml output):
               startstr = node['start']
               temp.startstr = Time.at(startstr)

Re: convert unix timestamp to date mysql understands

It only accepts an integer so you'll need to convert it before sending:

temp.startstr = Time.at(startstr.to_i)

Railscasts - Free Ruby on Rails Screencasts

Re: convert unix timestamp to date mysql understands

duh!  thanks so much - can u tell i'm a ruby newbie?:-)

Re: convert unix timestamp to date mysql understands

Nope, passing the wrong data type is seriously an easy mistake to make. I do it all the time.

Railscasts - Free Ruby on Rails Screencasts