public static function formatDate(\DateTimeInterface $dateTime, $format)
    {
        $phpFormats = array(
            self::DATE => "Y-m-d",
            self::DATE_AND_TIME => 'Y-m-d\TH:i:s\Z',
        );
        $phpFormat = $phpFormats[$format];

        return $dateTime->format($phpFormat);
    }
public static function formatDate(\DateTimeInterface $dateTime, $format)
    {
        $phpFormats = array(
            self::DATE => "Y-m-d",
            self::DATE_AND_TIME => 'Y-m-d\TH:i:s\Z',
        );
        $phpFormat = $phpFormats[$format];

        return $dateTime->format($phpFormat);
    }
public static function formatDate ( \ DateTimeInterface $ dateTime , $ format ) { $ phpFormats = array ( self :: DATE => "Y-m-d" , self :: DATE_AND_TIME => 'Y-m-d\TH:i:s\Z' , ) ; $ phpFormat = $ phpFormats [ $ format ] ; return $ dateTime -> format ( $ phpFormat ) ; }
Format DateTime string based on granularity

@param \DateTimeInterface $dateTime
@param string $format       Either self::DATE or self::DATE_AND_TIME

@return string
Format DateTime string based on granularity