Display time since last visit in PHP

Published on January 20, 2009 PHP Time Unix

This short snippet produces a “Twitter style” time difference, the idea is that it will round to the nearest time unit, and display only the integers on that unit. For example 1 minute ago, 2 weeks ago, 1 year ago

You can specify the word you want to appear instead of ago by setting the $ago argument to something else as well.

I moved this code to a Github Gist, available here: