How to Display Dates in The “Time Ago” Format in WordPress?


Do you like the way Gmail or blogs display time information as “x time units ago.” For example, “3 hours ago,” “2 weeks ago” or even “less than a minute ago.” Well, adding this functionality to your blog is actually quite simple to do – it actually uses a built-in WordPress feature to do it.

The WordPress function is known as human_time_diff(). To use it, you just post a line of code in your WordPress loop:

1
Posted <?php echo human_time_diff(get_the_time('U'), current_time('timestamp')) . ' ago'; ?>

Now just save your file and you’re done. From now on, your posts will be listed in the “time ago” format for easy readability. This WordPress customization will give you more personalization and informal look. Hope your reader will appreciate it!

Cheers!

By | On Monday, October 4th, 2010 | Under How To's | No Comments »


DO YOU NEED OUR HELP?

Contact our experts, most of the time we assist our readers free of charge.

Those who found this page were searching for:

  • time ago format
  • today date and time format in wordpress
  • wordpress time ago format
  • wordpress time_ago();
  • how to display wordorrss posts date like time ago format
  • wordpress timeago
  • wordpress time ago format
  • display dates as “time ago”, the easy way
  • wordpress "time ago"
  • timeago format for wordpress

Previous post:

Next post: