Change WordPress post date format to time ago

meks_time_ago_options

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…

Here this can help with function human_time_diff

<?php

global $post;
$orig_time = strtotime( $post->post_date );
return human_time_diff( $orig_time, current_time( 'timestamp' ) ).' '.__( 'ago' );

?>

 

meks_time_ago_options


Also published on Medium.

Leave a Reply

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