public static function dateDiff(DateTime $from = null, DateTime $to = null, string $format = 'Y-m-d H:i:s'): string
    {
        if (!$from) {
            return '';
        }
        if (!$to) { // if not define to then to date is set today
            $to = new DateTime();
        }
        return $from->diff($to)->format($format);
    }
public static function dateDiff(DateTime $from = null, DateTime $to = null, string $format = 'Y-m-d H:i:s'): string
    {
        if (!$from) {
            return '';
        }
        if (!$to) { // if not define to then to date is set today
            $to = new DateTime();
        }
        return $from->diff($to)->format($format);
    }
public static function dateDiff ( DateTime $ from = null , DateTime $ to = null , string $ format = 'Y-m-d H:i:s' ) : string { if ( ! $ from ) { return '' ; } if ( ! $ to ) { // if not define to then to date is set today $ to = new DateTime ( ) ; } return $ from -> diff ( $ to ) -> format ( $ format ) ; }
Date diff.

@param DateTime|null $from
@param DateTime|null $to
@param string        $format
@return string
@throws \Exception
Date diff .