# Date Formats

The `Date` class has a method `date_format()` and its subclass `DateTime` adds the method `time_format()`. There's also a `month_format()` on objects dealing with only a month. All these methods take an optional format string which can be either a named format or a custom format string. If no format is provided, a default sensible version is used. The default is indicated in the table below.

## Named Date Formats

The following named date formats are supported and localized for internationalization. The English representation is shown only as an example.

Method | Named Format | Default? | English Format | English Result
--- | --- | --- | --- | ---
date_format | short | X | %%m%%/%%d%%/%%yy%% | 2/5/80
date_format | med |  | %%mon%%. %%dayord%%, %%yyyy%% | Feb. 5th, 1980
date_format | med_day |  | %%da%%, %%mon%%. %%dayord%%, %%yyyy%% | Tue, Feb. 5th, 1980
date_format | long |  | %%month%% %%dayord%%, %%yyyy%% | February 5th, 1980
date_format | long_day |  | %%day%%, %%month%% %%dayord%%, %%yyyy%% | Tuesday, February 5th, 1980
time_format | short | X | %%hh%%:%%min%% %%a%%m | 12:34 am
month_format | short |  | %%m%%/%%yy%% | 04/03
month_format | med |  | %%mon%% %%yyyy%% | Apr 2003
month_format | long | X | %%month%% %%yyyy%% | April 2003

## Custom Date Formats

If you're making a style for yourself and don't care about keeping the date formats generic for internationalization, you can construct your own date format string with interpolated variables which you surround in double percent signs.

Variable | Description
--- | ---
m | Month, 1-12.
mm | Month, 01-12.
d | Day, 1-31.
dd | Day, 01-31.
yy | Year, two digits.
yyyy | Year, four digits.
mon | Short month name, translated. (English: Jan, Feb, …)
month | Long month name, translated. (English: January, February, …)
da | Short day of week, translated. (English: Sun, Mon, …)
day | Long day of week, translated. (English: Sunday, Monday, …)
dayord | Ordinal day of month, translated. (English: 1st, 2nd, 3rd, …)
H | Hour, 0-23.
HH | Hour, 00-23.
h | Hour, 1-12.
hh | Hour, 01-12.
min | Minute, 00-59.
sec | Second, 00-59.
a | "a" for am, "p" for pm.
A | "A" for am, "P" for pm.