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.
Comments