Have you ever wondered how some sites were able to show the bottom of each post, a formatted date (pretty date) which estimates the number of days, months or years between the publication of the post and today? e.g. "posted 5 weeks ago"
This snippet will allow you to do this easily!
You can improve this code by adding, for example, a dictionary of resources for the different languages of your application or website.