How to change the date and time format in WordPress

Dave Abargel,

Have you ever wanted to change the date format in WordPress? Maybe you wanted to shorten the format, hide the year, or display the time?
One of our users recently asked whether there is a way to change the date and time format / styling.
In this article, we will show you how to change the date and time format in WordPress.

Date and time settings

WordPress comes with built-in functions that allow users and developers to format the date and time. You can change the format under Settings > General in the WordPress admin panel and scroll down to the timezone section.
You can change the formatting under Settings > General in the WordPress admin panel and scroll down to the the time zone.

WordPress date and time settingsOriginal Hebrew WordPress interface. Follow the English instructions in this article; labels and positions may differ in newer versions.
WordPress date and time settings

Here you can choose a suitable timezone for your site, along with the date and time format.

There are several built-in, pre-prepared options from which you can choose by clicking the radio button, or you can enter a format you customized yourself.

Date and time format characters in WordPress

The date and time format is based on alphabetic characters that represent time formatting. For example, entering Y will display the year in four digits, such as 2016.
Entering a smaller value of y will display the year with two digits, such as 16. You can see the full list of The formatting characters here.

Below are examples of common date and time formatting characters:

M d, Y – will display December 31, 2015 (month as text, day as a number, year with 4 digits)
d M, Y – will display 31 December, 2015 (day as a number, month as text, year with 4 digits)
F, Y d – will display December, 2015 31 (month as text, year in 4 digits and day as a digit)
l ,F ,Y – will display Thursday,December,2015 (day as text, month, year with 4 digits)
H:i:s – will display 12:27:26 (hours:minutes:seconds)

You can try out different formats in the customization box, for the date and time settings.
After entering the format, WordPress will show you a preview of the date and time.

Preview of date and time format in WordPressOriginal Hebrew WordPress interface. Follow the English instructions in this article; labels and positions may differ in newer versions.
Preview of date and time format in WordPress

Once you save the settings, WordPress will use them on your site until you redefine the design.

How to display the time alongside the date in WordPress posts

Another common question on the subject is how to display the time next to the date in WordPress posts.
The hard but preferred solution is to edit the child theme of your WordPress site, and add the line below if you want to display the time.

  <?php echo get_the_time(); ?>

The code will display the time for the specific post or page.

Not all beginner users want to create a Child theme and fiddle with code. For them, there is an easier way to add the time next to the date.

Technically, when WordPress displays a date in your site's posts it actually displays the time as well,
However, since most people use date and time format characters only for formatting a date, the browser has no choice but to display the date only.
If you include time-related characters in the date format pattern, the time will be displayed as well. For example:

d/m/Y g:i – will display 31/12/2015 12:47

Similarly, you can also use date-related formatting characters in the time format field, if needed.
Depending on your needs, there are many things you can do with date and time formatting in WordPress.

For example, you can display the The post's last-updated time, in text or in numerals, instead of the publication date.
You can even display current date and time and relative dates, such as "This post was published 2 days ago".
But we will expand on this topic in a separate article, soon.

Dave Abargel

VP and founder of uPress, developer of Backend & Frontend, specializes in improving performance for WordPress websites, handling advanced security issues, and marketing on social networks. He is an active partner in a number of interesting projects in the field, such as WiPi, Enable, Greenicon, Speedom, and more.

  • You might be interested…

  • Your next chapter

    The idea is yours.
    The foundation is ours.

    Give your WordPress website room to grow.