I'm looking for a PHP function that has probably been written before... I don't know how to search the snippets section though...?
The function should take a timestamp and convert it into a context-senstive format relative to the current time...
so if I did date("Y-m-d h:i:s A", $timestamp) and got:
2002-09-24 10:00:00 PM
and it was now 10:15, I'd get:
15 Minutes Ago
if it was a 12 hours ago, I'd get:
12 Hours Ago
and if it was 75 hours ago, I'd get:
3 Days Ago
and if it was more than say 5 days, I'd get what would normally be returned by date("Y-m-d h:i:s A")...
It's not really a tough thing to write, but it takes some time to figure out where the breaks occur, or if you're really smart and do things like returning "This morning" if it's more appropriate than "12 Hours Ago".
If you have such a function, in any language, I'd appreciate a link. I'll convert it to PHP and add it to the snippets.