Convert Date to DateTime


#1

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?


#2

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


#3

I think it’s date_obj.to_datetime