public static function formatDate($date, $format = 'Y-m-d')
    {
        if (!$date) {
            return null;
        }
        $date = new DateTime($date);
        return $date->format($format);
    }
public static function formatDate($date, $format = 'Y-m-d')
    {
        if (!$date) {
            return null;
        }
        $date = new DateTime($date);
        return $date->format($format);
    }
public static function formatDate ( $ date , $ format = 'Y-m-d' ) { if ( ! $ date ) { return null ; } $ date = new DateTime ( $ date ) ; return $ date -> format ( $ format ) ; }
Returns formatted date.

@param string $date
@param string $format
@return null|string
Returns formatted date .