Skip to content
instance method

DateTime#strftime

(?::String format) -> ::String
strftime(format = '%FT%T%:z') → string

Returns a string representation of self, formatted according the given +format:

Example
DateTime.now.strftime # => "2022-07-01T11:03:19-05:00"

For other formats, see Formats for Dates and Times:

See also #second_fraction #to_date #second #to_datetime also in 4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0