Forum: Ruby on Rails Timestamp -> Date

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
2d66c63b4d8193d0279bd18200e109d3?d=identicon&s=25 Michael Boutros (michaelboutros)
on 2006-02-12 23:41
I have a timestamp in a row in my MySQL DB, and I can output the
timestamp, but what method could I use to turn the timestamp into the
date, like the PHP function date()?

Also, can I have the link to any place that lists all RoR
Methods/Classes that is not the official one? If no other ones exist, no
problem :)
Ac1da5d66d51a1c3b843221032247b30?d=identicon&s=25 Eric Goodwin (Guest)
on 2006-02-12 23:46
(Received via mailing list)
Hi,

mytimestamp.to_date() should work.

Not sure, but this might be edge rails only.
Check out the docs here:
http://rubymanual.org/module/ActiveSupport%3A%3ACo...

Eric




Michael Boutros wrote:

>I have a timestamp in a row in my MySQL DB, and I can output the
>timestamp, but what method could I use to turn the timestamp into the
>date, like the PHP function date()?
>
>Also, can I have the link to any place that lists all RoR
>Methods/Classes that is not the official one? If no other ones exist, no
>problem :)
>
>
>


--
Eric Goodwin
ericgoodwin.com
2d66c63b4d8193d0279bd18200e109d3?d=identicon&s=25 Michael Boutros (michaelboutros)
on 2006-02-13 00:16
Eric,

Nope, that gives me the undefinded method error.
Ac1da5d66d51a1c3b843221032247b30?d=identicon&s=25 Eric Goodwin (Guest)
on 2006-02-13 02:10
(Received via mailing list)
Are you running edge rails or are you running 1.0?
Edge rails seems quite stable and has quite a bit of added functionality
in it including the to_date function.
Trying running rake freeze_edge to get the latetest into your plugins
directory.

Other than that you can write your own helper.
Rails converts mysql datetime's into a Time so ...

class Time
    to_date()
        Date.new(self.year, self.month, self.day)
    end
end

They must be other ways too, but that should work.

Eric

Michael Boutros wrote:

>Eric,
>
>Nope, that gives me the undefinded method error.
>
>
>
--
Eric Goodwin
ericgoodwin.com
This topic is locked and can not be replied to.