public static function formatDate($format, $timestamp)
    {
        static $datesPatterns = null;
        static $timesPatterns = null;

        if ($datesPatterns === null || $timesPatterns === null) {
            $datesPatterns = "/\b(" . implode('|', array_keys(static::$_map['date'])) . ")\b(?![^']*'(?:(?:[^']*'){2})*[^']*$)/i";
            $timesPatterns = "/\b(" . implode('|', array_keys(static::$_map['time'])) . ")\b(?![^']*'(?:(?:[^']*'){2})*[^']*$)/i";
        }

        // normalize formats
        $result = preg_replace_callback($datesPatterns, function ($matches) use ($timestamp) {
            return date(static::$_map['date'][$matches[1]], $timestamp);
        }, trim($format));

        $result = preg_replace_callback($timesPatterns, function ($matches) use ($timestamp) {
            return date(static::$_map['time'][$matches[1]], $timestamp);
        }, $result);

        return str_replace('\'', '', $result);
    }
public static function formatDate($format, $timestamp)
    {
        static $datesPatterns = null;
        static $timesPatterns = null;

        if ($datesPatterns === null || $timesPatterns === null) {
            $datesPatterns = "/\b(" . implode('|', array_keys(static::$_map['date'])) . ")\b(?![^']*'(?:(?:[^']*'){2})*[^']*$)/i";
            $timesPatterns = "/\b(" . implode('|', array_keys(static::$_map['time'])) . ")\b(?![^']*'(?:(?:[^']*'){2})*[^']*$)/i";
        }

        // normalize formats
        $result = preg_replace_callback($datesPatterns, function ($matches) use ($timestamp) {
            return date(static::$_map['date'][$matches[1]], $timestamp);
        }, trim($format));

        $result = preg_replace_callback($timesPatterns, function ($matches) use ($timestamp) {
            return date(static::$_map['time'][$matches[1]], $timestamp);
        }, $result);

        return str_replace('\'', '', $result);
    }
public static function formatDate ( $ format , $ timestamp ) { static $ datesPatterns = null ; static $ timesPatterns = null ; if ( $ datesPatterns === null || $ timesPatterns === null ) { $ datesPatterns = "/\b(" . implode ( '|' , array_keys ( static :: $ _map [ 'date' ] ) ) . ")\b(?![^']*'(?:(?:[^']*'){2})*[^']*$)/i" ; $ timesPatterns = "/\b(" . implode ( '|' , array_keys ( static :: $ _map [ 'time' ] ) ) . ")\b(?![^']*'(?:(?:[^']*'){2})*[^']*$)/i" ; } // normalize formats $ result = preg_replace_callback ( $ datesPatterns , function ( $ matches ) use ( $ timestamp ) { return date ( static :: $ _map [ 'date' ] [ $ matches [ 1 ] ] , $ timestamp ) ; } , trim ( $ format ) ) ; $ result = preg_replace_callback ( $ timesPatterns , function ( $ matches ) use ( $ timestamp ) { return date ( static :: $ _map [ 'time' ] [ $ matches [ 1 ] ] , $ timestamp ) ; } , $ result ) ; return str_replace ( '\'' , '' , $ result ) ; }
Formats then given UNIX timestamp using the given jQuery format.

@param string $format jQuery format. e.g. `'today is:' yy-mm-dd`
@param int $timestamp Date as UNIX timestamp
@return string Formated date. e.g. `today is: 2018-09-09`
Formats then given UNIX timestamp using the given jQuery format .