src/Phlexible/Component/Formatter/AgeFormatter.php
public static function formatDate($firstDate, $secondDate = null, $returnAsArray = false)
    {
        if ($firstDate instanceof \DateTime) {
            $firstTimestamp = $firstDate->format('U');
        } elseif (is_int($firstDate)) {
            $firstTimestamp = strtotime($firstDate);
        } else {
            $firstTimestamp = strtotime($firstDate);
        }

        $secondTimestamp = null;
        if ($secondDate instanceof \DateTime) {
            $secondTimestamp = $secondDate->format('U');
        } elseif (is_int($secondDate)) {
            $secondTimestamp = strtotime($secondDate);
        } else {
            $secondTimestamp = strtotime($secondDate);
        }

        return self::formatTimestamp($firstTimestamp, $secondTimestamp, $returnAsArray);
    }
public static function formatDate($firstDate, $secondDate = null, $returnAsArray = false)
    {
        if ($firstDate instanceof \DateTime) {
            $firstTimestamp = $firstDate->format('U');
        } elseif (is_int($firstDate)) {
            $firstTimestamp = strtotime($firstDate);
        } else {
            $firstTimestamp = strtotime($firstDate);
        }

        $secondTimestamp = null;
        if ($secondDate instanceof \DateTime) {
            $secondTimestamp = $secondDate->format('U');
        } elseif (is_int($secondDate)) {
            $secondTimestamp = strtotime($secondDate);
        } else {
            $secondTimestamp = strtotime($secondDate);
        }

        return self::formatTimestamp($firstTimestamp, $secondTimestamp, $returnAsArray);
    }
public static function formatDate ( $ firstDate , $ secondDate = null , $ returnAsArray = false ) { if ( $ firstDate instanceof \ DateTime ) { $ firstTimestamp = $ firstDate -> format ( 'U' ) ; } elseif ( is_int ( $ firstDate ) ) { $ firstTimestamp = strtotime ( $ firstDate ) ; } else { $ firstTimestamp = strtotime ( $ firstDate ) ; } $ secondTimestamp = null ; if ( $ secondDate instanceof \ DateTime ) { $ secondTimestamp = $ secondDate -> format ( 'U' ) ; } elseif ( is_int ( $ secondDate ) ) { $ secondTimestamp = strtotime ( $ secondDate ) ; } else { $ secondTimestamp = strtotime ( $ secondDate ) ; } return self :: formatTimestamp ( $ firstTimestamp , $ secondTimestamp , $ returnAsArray ) ; }
Format the difference of 2 dates in a human readable form
If the second date is omitted, the current time will be used.

@param string $firstDate
@param string $secondDate
@param bool   $returnAsArray

@return string|array
Format the difference of 2 dates in a human readable form If the second date is omitted the current time will be used .