Operator | Example/Output | Notes |
---|---|---|
%Y | 2010, -0011, 14292 | Year with century, can be negative |
%C | 20 (in 2009) | Year / 100, rounded down |
%y | (00..99), 09 in 2009 | Year % 100, last two digits of year |
%m | (01..12) | Month of year, zero-padded |
%_m | ( 1..12) | Month of year, blank-padded |
%-m | (1..12) | Month of year, no padding |
%B | January | Name of month |
%^B | JANUARY | Uppercase name of month |
%b | Jan | Abbreviated month name, same as %h |
%h | Jan | Abbreviated month name, same as %b |
%^b | JAN | Uppercase and abbreviated month name |
%d | (01..31) | Day of month, zero-padded |
%-d | (1..31) | Day of month, no padding |
%e | ( 1..31) | Day of month, blank-padded |
%j | (001..366) | Day of year |
%A | Sunday | Full weekday name |
%^A | SUNDAY | Uppercase weekday name |
%a | Sun | Abbreviated weekday name |
%^a | SUN | Uppercase and abbreviated weekday name |
%u | (1..7) | Day of the week, where Monday is 1 |
%w | (0..6) | Day of the week, where Sunday is 0 |
%U | (00..53) | Week of the year, where Sunday starts the week |
%W | (00..53) | Week of the year, where Monday starts the week |
Operator | Example/Output | Notes |
---|---|---|
%H | (00..23) | Hour of day, 24-hour clock, zero-padded |
%k | ( 0..23) | Hour of day, 24-hour clock, blank-padded |
%I | (01..12) | Hour of day, 12-hour clock, zero-padded |
%l | ( 1..12) | Hour of day, 12-hour clock, blank-padded |
%P | am, pm | Meridian indicator, lowercase |
%p | AM, PM | Meridian indicator, uppercase |
%M | (00..59) | Minute of the hour |
%S | (00..59) | Second of the minute |
%L | (000..999) | Millisecond of the second |
%N | (000000000..999999999) | Nanosecond of the second, 9 digits |
%xN | %3N, x = 3, 6, 9, 12, 15, 21, 24 | Fractional second, where x is the number of digits |
%z | +0900 | Time zone as hour and minute offset from UTC |
%:z | +09:00 | Hour and minute offset with colon |
%::z | +09:00:00 | Hour, minute, and second offset with colon |
%Z | JST | Time zone abbreviation, or similar information. OS dependent. Does not work when time zone offset is used in original object. |
%s | 1463667344 | Unix Epoch, number of seconds since 1970-01-01 00:00:00 UTC |
Operator | Example/Output | Notes |
---|---|---|
%c | Thu May 19 10:34:37 2016 | Date and time (%a %b %e %T %Y) |
%D | 05/19/16 | Date (%m/%d/%y), same as %x |
%x | 05/19/16 | Date (%m/%d/%y), same as %D |
%F | 2016-05-19 | ISO 8601 date format (%Y-%m-%d) |
%v | 9-MAY-2016 | VMS date (%e-%^b-%4Y) |
%r | 10:38:08 AM | 12-hour time (%I:%M:%S %p) |
%R | 14:38 | 24-hour time (%H:%M) |
%T | 14:38:08 | 24-hour time (%H:%M:%S), same as %X |
%X | 14:38:08 | 24-hour time (%H:%M:%S), same as %T |
Operator | Example/Output | Notes |
---|---|---|
%n | \n | New-line character |
%t | \t | Tab character |
%% | % | Literal % character |
- | %-d, %-l | Don't pad numerical output |
_ | %_m | Use spaces for padding (blank-padded) |
0 | %0d | Use zeros for padding |
^ | %^a, %^B | Upcase the result string |
# | %#A, THURSDAY | Change case |
: | %:z | Use colons for %z |
Operator | Example/Output | Notes |
---|---|---|
%G | 2016 | ISO 8601 week-based year |
%g | (00.99), 09 in 2009 | Last 2 digits of ISO 8601 week-based year |
%V | (01..53) | Week number of ISO 8601 week-based year |