Formatting Date and Time.

Have you ever wanted to change the default date and time on your WordPress website, but you’re not sure what the ‘format characters’ are? Well in this post, I’ll explain how to format it to your liking as well as what each character represents.

For example, the default date format in WordPress is set up like this:

F j, Y

The capital F represents the full textual Month (January – December), the lowercase j represents the numeric day of the month without leading zero’s (1 – 31), and the capital Y represents the numeric year in four digits (2016).

The default time format in WordPress is set up like this:

g:i a

The lowercase g represents 12 hours without leading zero’s (1 – 12), the lowercase i represents minutes with leading zero’s (00 – 59), and the lowercase a represents meridiem of the day (am – pm).

Below is a list of format characters and what they stand for:
Day of Month

  • (d) Numeric, with leading zeros: 01–31
  • (j) Numeric, without leading zeros: 1–31
  • (S) The English suffix for the day of the month: st, nd or th in the 1st, 2nd or 15th.

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

  • (a) Lowercase: am, pm
  • (A) Uppercase: AM, PM
  • (g) Hour, 12-hour, without leading zeros: 1–12
  • (h) Hour, 12-hour, with leading zeros: 01–12
  • (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
  • (U) Unix timestamp (seconds since Unix Epoch): 1455880176

Here are some examples of date and time formats:

  • F j, Y g:i a – November 6, 2010 12:50 am
  • F j, Y – November 6, 2010
  • F, Y – November, 2010
  • g:i a – 12:50 am
  • g:i:s a – 12:50:48 am
  • l, F jS, Y – Saturday, November 6th, 2010
  • M j, Y @ G:i – Nov 6, 2010 @ 0:50
  • Y/m/d \a\t g:i A – 2010/11/06 at 12:50 AM
  • Y/m/d \a\t g:ia – 2010/11/06 at 12:50am
  • Y/m/d g:i:s A – 2010/11/06 12:50:48 AM
  • Y/m/d – 2010/11/06

Pin It on Pinterest