Change WordPress date format to “time ago”

Change WordPress date format to “time ago”

By default, WordPress offers you a nice solution to change your WordPress date format or time format in general settings of your admin dashboard. However, some people may prefer to have so called “time ago” format in the similar way to Twitter and Facebook style like posted “10 minutes ago”, “1 hour ago”, “3 hours ago”, etc…

This may be quite useful for websites with lots of content publishing very frequently. But in some cases it is just a matter of your personal taste. In this tutorial we are going to show you 3 ways of changing WordPress post date to time ago format and use it inside your WordPress themes.

1. Change WordPress post date format to time ago using custom template function

In the code snippet below, you will see custom function mks_time_ago() which you can use in any template of your WordPress theme instead of WordPress native function like the_date() and the_time().

Simple as that! Just keep in mind to add this function somewhere in the functions.php file of your theme. Now here is a basic usage example of the function inside of a WordPress theme template file.

2. Using time and date WordPress filter hooks

This solution is more suitable for those who don’t want to change the theme template files. In the following example we are using a callback function to override built in WordPress get_the_date and get_the_time functions and display time ago format automatically.

That’s it! Just paste this snippet in you theme functions.php file. Also, depending of your theme code and logic, you may only want to use time OR date filters so you can remove unnecessary hooks optionally.

3. Using Meks Time Ago WordPress Plugin

For all of you who are not familiar with coding we have created a plugin which will change your post date format to time ago and should work with any theme out of the box. Meks Time Ago WordPress plugin is 100% free and can be downloaded from official WordPress plugin repository.

Once you install and activate the plugin you can go and manage its simple options. The sweetest thing here is the limitation option so you can apply time ago format only for posts which are not older than specific time frame. For example, let’s say that you want to show time ago date format only for posts which are published in the last 5 days while other posts will be displayed in standard date format.


Live example?

Yes, we are using this “time ago” approach in our several WordPress themes so you can see it live in action on our demo websites for Voice Theme, Throne Theme, and Sidewalk Theme. Feel free to try and let us know what do you think in comments section.

Bojan Petrovic

Co-founder and WordPress developer at Meks. He has been involved in the business since 2009. creating themes, plugins and services on top of WordPress, continuously aiming to choose best approaches and work smarter, not harder.


Leave a comment
  • Hi,
    I am using “time ago” for my website where I am using herald theme. and I want to say that I am very happy with this theme and all plugins. you have an awesome collections of themes and plugins.

    And Thank you so much for providing quick response and Support to all my queries and concerns. Herald is beautifully designed and it’s very much easy to use even for a newbie like me. I will highly recommend your theme to all.
    Looking forward to a theme based on Beauty.
    Viaksh Sharma

  • Hi, I was searching for this long -time ago-, but I need to modify the “ago” word for “hace” because the site is in spanish, and the word “hace” goes before the time like this:

    1 hour ago to:
    Hace 1 hora (in spanish)

    I really apreciate your valuable help for this little problem 🙂

    Thank You!

  • Please where can I find the_date() code on the Meks Voice Theme. I need to do some modifications and make my date show the Last Updated Time because I am updating most of my posts and I will like my readers to know without actually putting it in the post. I have searched and searched please help

Leave a Reply

Your email address will not be published. Required fields are marked *