# To\_time doesn't do anything?

**URL:** <https://www.ruby-forum.com/t/to-time-doesnt-do-anything/163171>\
**Category:** Ruby\
**Created:** [March 17, 2009, 10:46pm UTC](https://www.ruby-forum.com/t/to-time-doesnt-do-anything/163171 "2009-03-17T22:46:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![loader](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/5daacb/32.png) [@loader](https://www.ruby-forum.com/u/loader)\
**Post date:** [March 17, 2009, 10:46pm UTC](https://www.ruby-forum.com/t/to-time-doesnt-do-anything/163171/1 "2009-03-17T22:46:44Z")

</div>

Hello everyone!

I have a date: creation\_date which is a DateTime object. I want to  
convert it in Time.  
So I used the function to\_time but there is no effect. My object remains  
a DateTime object.

(rdb:1) creation\_date  
Sun, 15 Mar 2009 09:30:00 -0800  
(rdb:1) creation\_date.class  
DateTime

(rdb:1) creation\_date.to\_time  
Sun, 15 Mar 2009 09:30:00 -0800  
(rdb:1) creation\_date.to\_time.class  
DateTime

Could you help me, please?

Thank you!

---

<div class="post-metadata">

**Author:** ![loader](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/5daacb/32.png) [@loader](https://www.ruby-forum.com/u/loader)\
**Post date:** [March 17, 2009, 11:41pm UTC](https://www.ruby-forum.com/t/to-time-doesnt-do-anything/163171/2 "2009-03-17T23:41:18Z")

</div>

Nobody knows?

---

<div class="post-metadata">

**Author:** ![loader](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/5daacb/32.png) [@loader](https://www.ruby-forum.com/u/loader)\
**Post date:** [March 18, 2009, 4:08am UTC](https://www.ruby-forum.com/t/to-time-doesnt-do-anything/163171/3 "2009-03-18T04:08:45Z")

</div>

Guillaume L. wrote:

> DateTime
> 
> (rdb:1) creation\_date.to\_time  
> Sun, 15 Mar 2009 09:30:00 -0800  
> (rdb:1) creation\_date.to\_time.class  
> DateTime
> 
> Could you help me, please?
> 
> Thank you!

I don’t see this behavior.

ruby 1.9.1p0 (2009-01-30 revision 21907) [i686-linux]  
irb 0.9.5(05/04/13)

irb(main):001:0\> require ‘date’  
=\> true  
irb(main):002:0\> DateTime.now.class  
=\> DateTime  
irb(main):003:0\> DateTime.now.to\_time  
=\> 2009-03-17 20:06:23 -0700  
irb(main):004:0\> DateTime.now.to\_time.class  
=\> Time

-Justin
