# Timestamp -\> Date

**URL:** <https://www.ruby-forum.com/t/timestamp-date/66283>\
**Category:** Rails\
**Created:** [February 12, 2006, 11:41pm UTC](https://www.ruby-forum.com/t/timestamp-date/66283 "2006-02-12T23:41:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![michaelb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b19c9b/32.png) [@michaelb](https://www.ruby-forum.com/u/michaelb)\
**Post date:** [February 12, 2006, 11:41pm UTC](https://www.ruby-forum.com/t/timestamp-date/66283/1 "2006-02-12T23:41:01Z")

</div>

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 🙂

---

<div class="post-metadata">

**Author:** ![michaelb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b19c9b/32.png) [@michaelb](https://www.ruby-forum.com/u/michaelb)\
**Post date:** [February 12, 2006, 11:46pm UTC](https://www.ruby-forum.com/t/timestamp-date/66283/2 "2006-02-12T23:46:47Z")

</div>

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%3ACoreExtensions%3A%3ATime%3A%3AConversions#meth\_to\_date](http://rubymanual.org/module/ActiveSupport%3A%3ACoreExtensions%3A%3ATime%3A%3AConversions#meth_to_date)

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](http://ericgoodwin.com)

---

<div class="post-metadata">

**Author:** ![michaelb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b19c9b/32.png) [@michaelb](https://www.ruby-forum.com/u/michaelb)\
**Post date:** [February 13, 2006, 12:16am UTC](https://www.ruby-forum.com/t/timestamp-date/66283/3 "2006-02-13T00:16:15Z")

</div>

Eric,

Nope, that gives me the undefinded method error.

---

<div class="post-metadata">

**Author:** ![michaelb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b19c9b/32.png) [@michaelb](https://www.ruby-forum.com/u/michaelb)\
**Post date:** [February 13, 2006, 2:10am UTC](https://www.ruby-forum.com/t/timestamp-date/66283/4 "2006-02-13T02:10:47Z")

</div>

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](http://ericgoodwin.com)
