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.
007bac1f27905cd4d5d88315e9b0093a?d=identicon&s=25 Guillaume Loader (loader)
on 2009-03-17 22: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!
007bac1f27905cd4d5d88315e9b0093a?d=identicon&s=25 Guillaume Loader (loader)
on 2009-03-17 23:41
Nobody knows?
6e366eb5a71be2bad7f383d42aeb4788?d=identicon&s=25 Justin Collins (Guest)
on 2009-03-18 04:08
(Received via mailing list)
Guillaume Loader 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.