From Joomla! Documentation

< API16:JDate
Revision as of 22:03, 12 May 2013 by JoomlaWikiBot (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Replacement filing cabinet.png
This Namespace has been archived - Please Do Not Edit or Create Pages in this namespace. Pages contain information for a Joomla! version which is no longer supported. It exists only as a historical reference, will not be improved and its content may be incomplete.


Gets the date as a formatted string.

[<! removed edit link to red link >]

<! removed transcluded page call, red link never existed >


format($format, $local=true)
Parameter Name Default Value Description
$format The date format specification string (see )
$local true True to return the date string in the local time zone, false to return it in GMT.


string The date string in the specified format format.

Defined in



jimport( '' );

Source Body

public function format($format, $local = true)
        // Do string replacements for date format options that can be translated.
        $format = preg_replace('/(^|[^\\\])D/', "\\1".self::DAY_ABBR, $format);
        $format = preg_replace('/(^|[^\\\])l/', "\\1".self::DAY_NAME, $format);
        $format = preg_replace('/(^|[^\\\])M/', "\\1".self::MONTH_ABBR, $format);
        $format = preg_replace('/(^|[^\\\])F/', "\\1".self::MONTH_NAME, $format);
        // If the returned time should not be local use GMT.
        if (!$local) {
        // Format the date.
        $return = parent::format($format);
        // Manually modify the month and day strings in the formated time.
        if (strpos($return, self::DAY_ABBR) !== false) {
                $return = str_replace(self::DAY_ABBR, $this->_dayToString(parent::format('w'), true), $return);
        if (strpos($return, self::DAY_NAME) !== false) {
                $return = str_replace(self::DAY_NAME, $this->_dayToString(parent::format('w')), $return);
        if (strpos($return, self::MONTH_ABBR) !== false) {
                $return = str_replace(self::MONTH_ABBR, $this->_monthToString(parent::format('n'), true), $return);
        if (strpos($return, self::MONTH_NAME) !== false) {
                $return = str_replace(self::MONTH_NAME, $this->_monthToString(parent::format('n')), $return);
        if (!$local) {
        return $return;

[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >


<CodeExamplesForm />