Here's another example from another project I worked on, this time in Python:

```python
def pretty_date(time=False):
    """
    Get a datetime object or a int() Epoch timestamp and return a
    pretty string like 'an hour ago', 'Yesterday', '3 months ago',
    'just now', etc
    """
    now = datetime.utcnow()
    if type(time) is int:
        diff = now - datetime.fromtimestamp(time)
    elif isinstance(time, datetime):
        diff = now - time
    elif not time:
        diff = now - now
    second_diff = diff.seconds
    day_diff = diff.days

    if day_diff < 0:
        return 'the future'

    if day_diff == 0:
        if second_diff < 10:
            return "just now"
        if second_diff < 60:
            return str(second_diff) + " second(s) ago"
        if second_diff < 120:
            return  "a minute ago"
        if second_diff < 3600:
            return str(second_diff / 60) + " minute(s) ago"
        if second_diff < 7200:
            return "an hour ago"
        if second_diff < 86400:
            return str(second_diff / 3600) + " hour(s) ago"
    if day_diff == 1:
        return "Yesterday"
    if day_diff < 7:
        return str(day_diff) + " day(s) ago"
    if day_diff < 31:
        return str(day_diff / 7) + " week(s) ago"
    if day_diff < 365:
        return str(day_diff / 30) + " month(s) ago"
    return str(day_diff / 365) + " year(s) ago"
```
Forgive the weird whitespace, it was copy-pasted from a weird syntax-highlighting editor.

This particular project deals with objects in the distant past, which is why it even bothers to include years. Under 40 lines if you don't include comments, and super straightforward. Again, could even be simpler, but it does all I needed it to do and nothing more.