News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

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


blog comments powered by Disqus

Similar Posts

Zend Developer Zone: Flex and PHP: Party in the Front, Business in the Back

Joshua Thijssen's Blog: Using vagrant and puppet to setup your symfony2 environment

Jared White\'s Blog: Willowgarden & Zend Framework at the same time!

Dave Dash's Blog: Finding things using Zend Search Lucene in symfony

Zend Developer Zone: Paging and Sorting Data with Zend Framework, Doctrine and PEAR (part 2)


Community Events

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


library opinion extension podcast unittest example introduction interview framework series release version php7 api laravel5 list language community voicesoftheelephpant laravel

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