in ,

Display Human Readable Time In WordPress

WordPress has a built-in function to display relative time in a human-readable format, like message, facebook, twitter etc. Human readable time formats means that the date of a post or comment is displayed as “x time ago”.

I have been using the human readable time format in my blog also. So In this article I put this quick tip for you to put on your blog also, if you like.

Usage of human_time_diff()

[php]<?php echo human_time_diff( get_the_time(‘U’), current_time(‘timestamp’) ) . ‘ ago’; ?>[/php]

human_time_diff() – determines difference between two times and returns in human readable format.
get_the_time() – Returns the time of the current post for use in PHP.
current_time() – Returns the blog’s current local time in the specified format.

What do you think?

Written by Sopheap

The goal of me is sharing new ideas, inspiration art, fresh and useful resource, covering web design and development, graphic design, advertising, mobile development and life style.

Comments

Leave a Reply

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

add pagination comment

Add Pagination To Your WordPress Theme

display useful button wp edtior

Display Useful Button In WordPress Editor