method
to_formatted_s
v2.0.1 -
Show latest stable
-
2 notes -
Class: ActiveSupport::CoreExtensions::DateTime::Conversions
- 1.0.0
- 1.1.0
- 1.1.1
- 1.1.6
- 1.2.0
- 1.2.6
- 2.0.0 (0)
- 2.0.1 (0)
- 2.0.3 (38)
- 2.1.0 (0)
- 2.2.1 (0)
- 2.3.2 (0)
- 2.3.8 (0)
- 3.0.0
- 3.0.5
- 3.0.7
- 3.0.9
- 3.1.0
- 3.2.1
- 3.2.3
- 3.2.8
- 3.2.13
- What's this?
Register or
log in
to add new notes.
georges -
April 21, 2009
moiristo -
January 21, 2010
3 thanks
Format not coming out properly?
Date, Time and DateTime may have different formats defined.
If you do:
@user.created_at.to_formatted_s(:long_ordinal)
You will get (or something):
April 16th, 2009 22:03
But if you do:
@user.created_at.to_date.to_formatted_s(:long_ordinal)
You will get:
April 16th, 2009
So, be sure you know which one you are working with.
2 thanks
W3CDTF Format
Here is the formatted string for the W3CDTF datetime format (http://www.w3.org/TR/NOTE-datetime). It has a semicolon in the timezone part, therefore you cannot use ā%zā:
Time::DATE_FORMATS[:w3cdtf] = lambda { |time| time.strftime("%Y-%m-%dT%H:%M:%S#{time.formatted_offset}") }


