Forum: Ruby on Rails Convert Date to DateTime

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.
David (Guest)
on 2009-06-02 03:45
(Received via mailing list)
The method I am using to convert Date objects to DateTime objects is:

date_obj = DateTime.parse(Date.to_s)

Is this an okay way to go about doing this?  Or is there a more
efficient way?
Rick D. (Guest)
on 2009-06-02 03:55
(Received via mailing list)
On Mon, Jun 1, 2009 at 7:44 PM, David <removed_email_address@domain.invalid> 
wrote:
>
> The method I am using to convert Date objects to DateTime objects is:
>
> date_obj = DateTime.parse(Date.to_s)
>
> Is this an okay way to go about doing this?  Or is there a more
> efficient way?

Well, on Rails you can do

date_obj.to_date_time

It's part of ActiveSupport

--
Rick DeNatale

Blog: http://talklikeaduck.denhaven2.com/
Twitter: http://twitter.com/RickDeNatale
WWR: http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn: http://www.linkedin.com/in/rickdenatale
cash22 (Guest)
on 2012-10-11 00:38
(Received via mailing list)
I think it's date_obj.to_datetime
This topic is locked and can not be replied to.