Get pretty date differences in PHP

Today I needed a quick way to get the time difference from an UNIX timestamp to the current date. To get an idea, it’s like the little date you see on Twitter.com, for example “5m” if the tweet was posted 5 minutes ago.

Here’s my quick-and-dirty PHP code, it just takes the timestamp as an input and returns the formatted output. Feel free to fork it and improve it!

View the code on Gist.