PHP: producing relative date/time from timestamps
- by KeyStroke
Hi,
I'm basically trying to convert a Unix timestamp (the time() function) to a relative date/time that's both compatible with past and future date. So outputs could be:
2 weeks ago
1 hour and 60 minutes ago
15 minutes and 54 seconds ago
after 10 minutes and 15 seconds
First I tried to code this, but made a huge unmaintainable function, and then I searched the internet for a couple of hours, yet all I can find are scripts that produce only one part of the time (e.h: "1 hour ago" without the minutes).
Do you have a script that already does this? If so, I'd really appreciate if you could share it.
Thanks.