Forum: Ruby to_time doesn't do anything??

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.
Guillaume L. (Guest)
on 2009-03-17 23:46
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!
Guillaume L. (Guest)
on 2009-03-18 00:41
Nobody knows?
Justin C. (Guest)
on 2009-03-18 05:08
(Received via mailing list)
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
This topic is locked and can not be replied to.