News Feed
Jobs Feed
Sections




Recent Jobs

News Archive
Federico Cargnelutti's Blog:
Format a time interval with the requested granularity
June 25, 2009 @ 12:56:51

Federico Cargnelutti has posted a class (DateIntervalFormat) that gives you the difference between a date and "now" in words rather than an integer.

This class, a refactored version of Drupal's format_interval function, makes it relatively easy to format an interval value. The format will automatically format as compactly as possible. For example: if the difference between the two dates is only a few hours and both dates occur on the same day, the year, month, and day parts of the date will be omitted.

So, instead of getting a value of "86400 seconds" you'd get back something like "5 days 3 hours".

0 comments voice your opinion now!
tutorial granularity time format



Similar Posts

PHPBuilder.com: Pro PHP Security / Preventing SQL Injection

Web Development Blog: Upload images for usage in TinyMCE

eWeek: PHP Puts Mainframe Developers in Prime Time

Bill's IIS Blog: PHP on IIS7 w/FastCGI

DevShed: Using Advanced Functions to Maintain the State of Applications with PHP Sessions


Community Events









Don't see your event here?
Let us know!


opinion facebook symfony performance wordpress conference windows zendframework microsoft codeigniter extension developer feature podcast job sqlserver hiphop release framework zend

All content copyright, 2010 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework