PHP: Date Pretty Difference

This function will return a pretty date difference Requires PHP 5.2.0 or higher

/**
* @param   string date
* @param   string date
* @return  string
*/

function prettyDateDiff ( $date_started , $date_ended ) {
return DateTime :: createFromFormat ( 'Y-m-d H:i:s' , $date_started ) -> diff ( DateTime :: createFromFormat ( 'Y-m-d H:i:s' , $date_ended ) ) -> format ( '%a days %H hours %i minutes' ) ;
}

Example Usage:

echo prettyDateDiff ( '2013-10-08 09:12:00' , '2013-10-15 10:43:00' ) ;

Returns: 7 days 01 hours 31 minutes

If you have any questions, make sure to add it to the comments below.