Change WordPress post date format to time ago


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


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




Also published on Medium.

Leave a Reply

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