Display human friendly relative dates and times 0.9
Free PHP script: Display human friendly relative dates and times is 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"
"Next Tuesday"
"Next month"
This PHP script converts an SQL date into a human friendly string representing that date and time relative to now.
The Code:
The code for using this script is really simple. Just include the script, instantiate the object, and pass it an SQL date:
require_once('humanRelativeDate.class.php');
$humanRelativeDate = new HumanRelativeDate();
$string = $humanRelativeDate->getTextForSQLDate($sql_date);
What could be easier?
Daylight Saving:
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.
Legalese:
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.
More popular Date & Time
- Ultimate PHP Date Time Script 1.0.0 (2 years, 8 months 13 days ago)
- Display human friendly relative dates and times 0.9 (2 years, 2 months 21 days ago)
- PHP dateRange Class 1.0 (2 years, 8 months 13 days ago)
- Opening hours 2.0 (2 years, 8 months 13 days ago)
- Digital Clock 1.0 (14 years, 2 months 23 days ago)
Listing Files

index.php- 923 Bytes
- 05/10/2010 11:17:12

humanRelativeDate.class.php- 5.4 KB
- 05/10/2010 18:12:14

._index.php- 171 Bytes
- 05/10/2010 11:17:12

._humanRelativeDate.class.php- 171 Bytes
- 05/10/2010 18:12:14
- FREE MySQL Cloud Database Super Simple, Zero-Management MySQL Cloud DB. Use It FREE!
- Pinterest clone Start your own pin board social network today. Get Pintastic and start your own pinterest clone network.
- MYRE Real Estate Software Professional Real Estate solutions by MYREPHP PROGRAMMING!
