Tuesday, June 27, 2006

Ruby convert Time to Date

On more than one occasion I've needed to convert a Time object to a Date. Generally, I use the following code:
Date.parse(Time.now.strftime('%Y/%m/%d'))
I have two questions.



Comments:
ActiveSupport implements Time#to_date. If you're not working on a Rails application, you could always borrow their implementation.
 
Perfect. Thanks.
 
Post a Comment

<< Home

This page is powered by Blogger. Isn't yours?