In this tutorial I will show you how to get WordPress post published date as time difference i.e., 2 days ago, 5 months ago etc.
Here is the code to get in this format
$time = get_post_time("U", true, $post_id);
$time = human_time_diff($time, current_time('timestamp')) . " ago";