public static function formatOrNull($dateTime, $format = 'Y-m-d H:i:s', $null = null)
    {
        if ($dateTime instanceof \DateTime) {
            return $dateTime->format($format);
        } elseif (ValueHelper::isDateTime($dateTime)) {
            return static::stringToDateTime($dateTime)->format($format);
        } else {
            return $null;
        }
    }
public static function formatOrNull($dateTime, $format = 'Y-m-d H:i:s', $null = null)
    {
        if ($dateTime instanceof \DateTime) {
            return $dateTime->format($format);
        } elseif (ValueHelper::isDateTime($dateTime)) {
            return static::stringToDateTime($dateTime)->format($format);
        } else {
            return $null;
        }
    }
public static function formatOrNull ( $ dateTime , $ format = 'Y-m-d H:i:s' , $ null = null ) { if ( $ dateTime instanceof \ DateTime ) { return $ dateTime -> format ( $ format ) ; } elseif ( ValueHelper :: isDateTime ( $ dateTime ) ) { return static :: stringToDateTime ( $ dateTime ) -> format ( $ format ) ; } else { return $ null ; } }
Tries to format given input.

@param string|\DateTime $dateTime
@param string           $format
@param null             $null

@return null|string
Tries to format given input .