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.
Michael B. (Guest)
on 2006-02-13 00: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 :)
Eric G. (Guest)
on 2006-02-13 00: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 B. 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 G.
ericgoodwin.com
Michael B. (Guest)
on 2006-02-13 01:16
Eric,

Nope, that gives me the undefinded method error.
Eric G. (Guest)
on 2006-02-13 03: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 B. wrote:

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