I have a ActiveSupport::TimeWithZone instance like 2014-12-22 05:54:34 UTC
, but I only want to keep the date info 2014-12-22
I tried Rail's to_formatted_s
, but it didn't work for me.
<%= item.updated_at.to_formatted_s(:db) %>
Which displays: 2014-12-22 05:54:34
You can use strftime
:
> date_time.strftime('%Y-%m-%d')
where,
%Y - Year with century
%m - Month of the year (01..12)
%d - Day of the month (01-31)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With