Reputation: 645
In my Rails database, I have a timestamp that looks like this 2010-12-22 18:21:46 UTC
. I need a way to just get the date 2010-12-22
from it without re-doing the database.
Upvotes: 43
Views: 43150
Reputation: 139
To get the String you're looking for
your_date.strftime("%F")
below link u can get more type of date. http://ruby-doc.org/core-2.2.0/Time.html#method-i-strftime
Upvotes: 1
Reputation: 25994
To get the String
you're looking for
your_date.strftime("%Y-%m-%d")
Not sure what you mean about modifying the database?
Upvotes: 18