Every time I need to format ruby’s strftime options, I need to search for it on the internet. Putting them down here so that I don’t have to do that again!
Date Formatting 1
%Y
Year with century (e.g. 2015, 1995, etc)
%m
Month of the year, zero-padded (01..12)
%B
The full month name (e.g. January)
%b
The abbreviated month name (e.g. Jan)
%d
Day of the month, zero-padded (01..31)
%j
Day of the year (001..366)
Flags
–
Don’t pad a numerical output
_
Use spaced for padding
0
Use zeros for padding
^
Upcase the result string
#
Change case
:
Use colons for %z
Date Formatting 2
%C
Year / 100 (round down. e.g. 20 in 2015)
%y
Year % 100 (00…99)
%_m
Month of the year, blank-padded (_1..12)
%-m
Month of the year, no-padding (1..12)
%^B
The full month name uppercased (e.g. JANUARY)
%^b
The abbreviated month name uppercased (e.g. JAN)
%h
Equivalent to %b (abbreviated month name)
%-d
Day of the month, no-padding (1..31)
%e
Day of the month, blank-padded (_1..31)
Time Formatting 1
%H
Hour of the day, 24-hour clock, zero-padded (00..23)
%k
Hour of the day, 24-hour clock, blank-padded (_0..23)
%I
Hour of the day, 12-hour clock, zero-padded (01..12)
%l
Hour of the day, 12-hour clock, blank-padded (_1..12)
%P
Meridian indicator, lowercase (am or pm)
%p
Meridian indicator, uppercase (AM or PM)
%M
Minute of the hour (00..59)
%S
Second of the minute (00..59)
Time Zone Formatting
%z
Time zone as hour and minute offset from UTC (e.g. +0900)
%:z
Time zone hour and minute offset from UTC with a colon (e.g. +09:00)
%::z
Time zone hour, minute and second offset from UTC (e.g. +09:00:00)
%:::z
Time zone hour, minute and second offset from UTC (e.g. +09, +09:30, +09:30:30)
%Z
Time zone abbreviation name or something similar information
Weekday Formatting
%A
The full weekday name (e.g. Sunday)
%^A
The full weekday name uppercased (e.g. SUNDAY)
%a
The abbreviated weekday name (e.g. Sun)
%^a
The abbreviated weekday name uppercased (e.g. SUN)
%u
Day of the week starting Monday (1..7)
%w
Day of the week starting Sunday (0..6)
Week Formatting
%G
The week-based year
%g
The last 2 digits of the week-based year (00..99)
%V
Week number of the week-based year (01..53)
%U
Week number of the year. Week starts with Sunday (00..53)
%W
Week number of the year. Week starts with Monday (00..53)
Seconds Formatting
%s
Number of seconds since 1970-01-01 00:00:00 UTC
%Q
Number of milliseconds since 1970-01-01 00:00:00 UTC