Codex tools: Log in / create account
Languages: English • 日本語 • Русский • 中文(简体) • (Add your language)
Certain WordPress tag functions are used to display or return date and time information; the_date() and the_time() are examples of this. Some of these functions accept a parameter called a format string that allows you to determine how the date is going to be displayed. The format string is a template in which various parts of the date are combined (using "format characters") to generate a date in the format specified.
For example, the format string:
l, F j, Y
creates a date that look like this:
Friday, September 24, 2004
Here is what each format character in the string above represents:
l = Full name for day of the week (lower-case L).
F = Full name for the month.
j = The day of the month.
S = The English suffix for the day of the month (e.g st, nd or th in the 1st, 2nd or 15th.)
Y = The year in 4 digits. (lower-case y gives the year's last 2 digits)
WordPress is written in the programming language PHP. The date formatting functions in WordPress use PHP's built-in date formatting functions. You can use the table of date format characters on the PHP website as a reference for building date format strings for use in WordPress. Here is a table of some of the more useful items found there:
| Day of month | ||
| d | Numeric, with leading zeros | 01–31 |
| j | Numeric, without leading zeros | 1–31 |
| S | English ordinal suffix, use after j | st, nd, rd or th |
| Weekday | ||
| l | Full name (lowercase 'L') | Sunday – Saturday |
| D | Three letter name | Mon – Sun |
| Month | ||
| m | Numeric, with leading zeros | 01–12 |
| n | Numeric, without leading zeros | 1–12 |
| F | Textual full | January – December |
| M | Textual three letters | Jan - Dec |
| Year | ||
| Y | Numeric, 4 digits | Eg., 1999, 2003 |
| y | Numeric, 2 digits | Eg., 99, 03 |
| Time | ||
| g | Hour, 12-hour, without leading zeros | 1–12 |
| h | Hour, 12-hour, with leading zeros | 01–12 |
| a | Lowercase | am, pm |
| A | Uppercase | AM, PM |
| G | Hour, 24-hour, without leading zeros | 0-23 |
| H | Hour, 24-hour, with leading zeros | 00-23 |
| i | Minutes, with leading zeros | 00-59 |
| s | Seconds, with leading zeros | 00-59 |
| T | Timezone abbreviation | Eg., EST, MDT ... |
| Full Date/Time | ||
| c | ISO 8601 | 2004-02-12T15:19:21+00:00 |
| r | RFC 2822 | Thu, 21 Dec 2000 16:01:07 +0200 |
To localize dates, use the date_i18n() function.