Datetime type to Date object

Context:
I have a User model with a last_logged_in_date that is a ‘datetime’
column in the DB.

user.last_logged_in_date gives you something like: Mon Oct 02 20:25:25
Pacific Standard Time 2006

Is there anyway to easliy convert that into a Date object so that I can
use Ruby’s Date class to handle it?

Thanks,
Nelson

I have a User model with a last_logged_in_date that is a ‘datetime’
column in the DB.

user.last_logged_in_date gives you something like: Mon Oct 02 20:25:25
Pacific Standard Time 2006

Is there anyway to easliy convert that into a Date object so that I can
use Ruby’s Date class to handle it?

http://api.rubyonrails.org/classes/ActiveSupport/CoreExtensions/Time/Conversions.html#M000227

If to_date doesn’t work exactly, look at it’s source.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs