Browse by category

Date Patterns

OperatorExample/OutputNotes
%Y2010, -0011, 14292Year with century, can be negative
%C20 (in 2009)Year / 100, rounded down
%y(00..99), 09 in 2009Year % 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
%BJanuaryName of month
%^BJANUARYUppercase name of month
%bJanAbbreviated month name, same as %h
%hJanAbbreviated month name, same as %b
%^bJANUppercase 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
%ASundayFull weekday name
%^ASUNDAYUppercase weekday name
%aSunAbbreviated weekday name
%^aSUNUppercase 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

Back to top

Time Patterns

OperatorExample/OutputNotes
%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
%Pam, pmMeridian indicator, lowercase
%pAM, PMMeridian 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, 24Fractional second, where x is the number of digits
%z+0900Time zone as hour and minute offset from UTC
%:z+09:00Hour and minute offset with colon
%::z+09:00:00Hour, minute, and second offset with colon
%ZJSTTime zone abbreviation, or similar information. OS dependent. Does not work when time zone offset is used in original object.
%s1463667344Unix Epoch, number of seconds since 1970-01-01 00:00:00 UTC

Back to top

Combination Patterns

OperatorExample/OutputNotes
%cThu May 19 10:34:37 2016Date and time (%a %b %e %T %Y)
%D05/19/16Date (%m/%d/%y), same as %x
%x05/19/16Date (%m/%d/%y), same as %D
%F2016-05-19ISO 8601 date format (%Y-%m-%d)
%v 9-MAY-2016VMS date (%e-%^b-%4Y)
%r10:38:08 AM12-hour time (%I:%M:%S %p)
%R14:3824-hour time (%H:%M)
%T14:38:0824-hour time (%H:%M:%S), same as %X
%X14:38:0824-hour time (%H:%M:%S), same as %T

Back to top

Literals and Flags

OperatorExample/OutputNotes
%n\nNew-line character
%t\tTab character
%%%Literal % character
-%-d, %-lDon't pad numerical output
_%_mUse spaces for padding (blank-padded)
0%0dUse zeros for padding
^%^a, %^BUpcase the result string
#%#A, THURSDAYChange case
:%:zUse colons for %z

Back to top

ISO-8601 Week Patterns

  • The first week of the year must start on a Monday and include Jan 04
  • Otherwise, days before this week are in the last week of the previous year
OperatorExample/OutputNotes
%G2016ISO 8601 week-based year
%g(00.99), 09 in 2009Last 2 digits of ISO 8601 week-based year
%V(01..53)Week number of ISO 8601 week-based year

Back to top