Display latest post in wordpress with Time ago format

There are so many ways to get latest post date in time ago format But WordPress provide a simple function human_time_diff() to get the time difference.

$postslist = get_posts('numberposts=1');
foreach ($postslist as $post) :
<div><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></div>
<div>By <?php the_author(); ?>  |  <?php echo human_time_diff(get_the_time('U'),current_time('timestamp')) . ' ago'; ?></div>
<?php endforeach; ?>

Share With Friends

Speak Your Mind


Time limit is exhausted. Please reload CAPTCHA.