PHP Pretty Date
This article is old and may contain information that is outdated, irrelevant, or—dare I say it—no longer accurate. Read with care!
- Requires PHP >= 5.10, due to the usage of PHP’s new DateTimeclass.
// pass in a String DateTime, compared to another String DateTime (defaults to now)
$myString = Date_Difference::getStringResolved('-7 weeks');
$myString = Date_Difference::getStringResolved('-7 weeks', '+1 week');
// pass in a DateTime object, compared to another DateTime object (defaults to now)
// useful with the Propel ORM, which uses DateTime objects internally.
$myString = Date_Difference::getString(new DateTime('-7 weeks'));
$myString = Date_Difference::getString(new DateTime('-7 weeks'), new DateTime('+1 week'));
Download PHP Pretty Date (PHP 5.10 , 1.86KB)
Ranie Disqus24 Apr 2009
Devan Disqus28 May 2009
Jelle Disqus18 Feb 2010
Benjamin C. Disqus02 May 2011
Woody Disqus12 Jul 2011
Zach Leatherman Disqus12 Jul 2011