For a Good Strftime
Easy Skeezy Ruby Date/Time Formatting
By Mike Buckbee
@mbuckbee
Date
Format
PRESETS
BUILD YOUR OWN
REFERENCE
Strftimified result
Friday, Jun 02
Friday, Jun 02
06/02/2023
06- 2-23 21:45
Jun 2, 9:45 PM
June 2023
Jun 02, 2023
Fri, 2 Jun 2023 21:45:31 +0000
2023-06-02T 9:45:31+0000
09:45:31 PM
21:45:31
2 Jun 2023 21:45:31PM
02.06.23
Friday, 02 Jun 2023 9:45 PM
Strftimified result
Drag date elements here
Fri
Friday
Jun
June
2
9
06
45
PM
31
5
23
2023
+0000
UTC
Strftimified result
October 2018
Seconds
%S - Second of the minute (00..60)
%L - Millisecond of the second (000..999)
%s - Number of seconds since 1970-01-01 00:00:00 UTC.
Minutes
%M - Minute of the hour (00..59)
Hours
%H - Hour of the day, 24-hour clock (00..23)
%I - Hour of the day, 12-hour clock (01..12)
%k - Hour of the day, 24-hour clock, blank-padded ( 0..23)
%l - Hour of the day, 12-hour clock, blank-padded ( 0..12)
Days
%a - Abbreviated weekday name (“Sun”)
%A - Full weekday name (Sunday)
%w - Day of the week (Sunday is 0, 0..6)
%u - Day of the week (Monday is 1, 1..7)
%d - Day of the month (01..31)
%e - Day of the month (1..31)
%j - Day of the year (001..366)
Weeks
%w - Day of the week (Sunday is 0, 0..6)
%U - Week number of the current year, starting with the first Sunday as the first day of the first week (00..53)
%V - Week number of year according to ISO 8601 (01..53)
Months
%b - Abbreviated month name (Jan)
%B - Full month name (January)
%m - Month of the year (01..12)
Years
%y - Year without a century (00..99)
%Y - Year with century
Others
%p - Meridian indicator (AM or PM)
%P - Meridian indicator (“am” or “pm”)
%c - Preferred local date and time representation
%Z - Time zone name
%% - Literal % character
%C - Century (20 in 2009)
%D - U.S. Date (%m/%d/%y)
%n - Newline (n)
%t - Tab character (t)
If you've found ForAGoodStrftime useful today, do me a favor and check out
Expedited CDN on Heroku
. It's a Content Delivery Network tuned for Heroku.
- Mike