Format Code List
The table below shows all the format codes that you can use.

Sun, Mon, ...
%a Abbreviated weekday name.

Sunday, Monday, ...
%A Full weekday name.

0, 1, ..., 6
%w Weekday as a decimal number.

01, 02, ..., 31
%d Day of the month as a zero-padded decimal.

1, 2, ..., 30
%-d Day of the month as a decimal number.

Jan, Feb, ..., Dec
%b Abbreviated month name.

January, February, ...
%B Full month name.

01, 02, ..., 12
%m Month as a zero-padded decimal number.

1, 2, ..., 12
%-m Month as a decimal number.

00, 01, ..., 99
%y Year without century as a zero-padded decimal number.

0, 1, ..., 99
%-y Year without century as a decimal number.

2013, 2019 etc.
%Y Year with century as a decimal number.

00, 01, ..., 23
%H Hour (24-hour clock) as a zero-padded decimal number.

0, 1, ..., 23
%-H Hour (24-hour clock) as a decimal number.

01, 02, ..., 12
%I Hour (12-hour clock) as a zero-padded decimal number.

1, 2, ... 12
%-I Hour (12-hour clock) as a decimal number.

AM, PM
%p Locale’s AM or PM.

00, 01, ..., 59
%M Minute as a zero-padded decimal number.

0, 1, ..., 59
%-M Minute as a decimal number.

00, 01, ..., 59
%S Second as a zero-padded decimal number.

0, 1, ..., 59
%-S Second as a decimal number.

000000 - 999999
%f Microsecond as a decimal number, zero-padded on the left.

UTC offset
%z UTC offset in the form +HHMM or -HHMM.

Time zone name
%Z Time zone name.

001, 002, ..., 366
%j Day of the year as a zero-padded decimal number.

1, 2, ..., 366
%-j Day of the year as a decimal number.

00, 01, ..., 53
%U Week number of the year (Sunday as the first day of the week). All days in a new year preceding the first Sunday are considered to be in week 0.

00, 01, ..., 53
%W Week number of the year (Monday as the first day of the week). All days in a new year preceding the first Monday are considered to be in week 0.

Mon Sep 30 07:06:05 2013
%c Locale’s appropriate date and time representation.

09/30/13
%x Locale’s appropriate date representation.

07:06:05
%X Locale’s appropriate time representation.

%
%% A literal '%' character.
Was this article helpful?
Cancel
Thank you!