How to configure custom date and time formats in WordPress
In WordPress you can change how the date and time are displayed on the frontend of the site. To do this, log into the admin panel and go to Settings>General. There you can select a preconfigured format for the date and one for the time, or you can set a custom one.
The custom format is configured by typing a string of characters which corresponds to a particular format. Each character in the string matches a certain set of values that are shown on the frontend.
Let's start with formatting the date. The character l (lowercase L) stands for the full name of the week day (e.g. Monday, Tuesday), while D stands only for the first three letters of the day (e.g. Mon). d is for the day of the month represented with digits with a leading zero (e.g. 01, 02, 21, etc.), while j does the same thing but with no leading zero (e.g. 1, 2, 21, etc.). To show the full name of the month use F (January, February, etc.); M will display an abbreviation of the name (e.g. Jan, Feb). To show the month using digits use m for the number of the month with a leading zero (01-12) and n for the number with no leading zero (1-12). The year is represented with the letter Y. Other characters in the string are represented literally. For example, the string M d, Y will match dates with the format Sep 05, 2014.
When it comes to formatting the time use g to show the hours with a 12-hour format and no leading zero (1-12), h to show the hours in a 12-hour format but with a leading zero (01-12); use G to show the hours in a 24-hour format with no leading zero (0-23) and H to show the hours using a 24-hour format with a leading zero (00-23). For the minutes use i and for the seconds s. If you want to show AM or PM after the time use a for lowercase and A for uppercase. For example, the string h:i:s A will show the time with the format 06:29:43 PM.
For some more details, examples and reference tables check out the tutorial on how to manage custom date and time formats in WordPress.