One of the really lovely features that social sites like Twitter and Facebook give to users is a nice friendly way of displaying relative dates and times. For example:
"1 hour ago"
This PHP class converts an SQL date into a human friendly string representing that date and time relative to now.
Just enter an SQL formatted date or date/time string below:
The code for using this class is really simple. Just include the class, instantiate the object, and pass it an SQL date:
$humanRelativeDate = new HumanRelativeDate();
$string = $humanRelativeDate->getTextForSQLDate($sql_date);
What could be easier?
Please note that this script uses 86400 seconds as its basis for events less than 2 days away, and therefore does not correctly account for daylight saving days, where the day can be either 82800 in case its the winter change or 90000 for the summer change.
As a result, when viewing this script on a DST day, some unexpected results may occur: for example, an event which occurs on midnight the day after may be labelled as occuring "in two days", rather than "tomorrow"
We may address this in a future version.
Whilst we've made every effort to make this script both bomb and idiot proof, the usual disclaimers apply: Invent Partners accepts no liability for any loss or damages incurred by the use or misuse of this script. Sorry.