MediaWiki  master
DateFormatter Class Reference

Date formatter. More...

Public Member Functions

 __construct (Language $lang)
 
 reformat ( $preference, $text, $options=[])
 

Static Public Member Functions

static getInstance (Language $lang=null)
 Get a DateFormatter object. More...
 

Detailed Description

Date formatter.

Recognises dates and formats them according to a specified preference.

This class was originally introduced to detect and transform dates in free text. It is now only used by the {{#dateformat}} parser function. This is a very rudimentary date formatter; Language::sprintfDate() has many more features and is the correct choice for most new code. The main advantage of this date formatter is that it is able to format incomplete dates with an unspecified year.

Definition at line 37 of file DateFormatter.php.

Constructor & Destructor Documentation

◆ __construct()

DateFormatter::__construct ( Language  $lang)
Parameters
Language$langIn which language to format the date

Definition at line 128 of file DateFormatter.php.

References $lang.

Member Function Documentation

◆ getInstance()

static DateFormatter::getInstance ( Language  $lang = null)
static

Get a DateFormatter object.

Deprecated:
since 1.33 use MediaWikiServices::getDateFormatterFactory()
Parameters
Language | null$langIn which language to format the date Defaults to the site content language
Returns
DateFormatter

Definition at line 167 of file DateFormatter.php.

References $lang.

◆ reformat()

DateFormatter::reformat (   $preference,
  $text,
  $options = [] 
)
Parameters
string$preferenceUser preference, must be one of "default", "dmy", "mdy", "ymd" or "ISO 8601".
string$textText to reformat
array$optionsIgnored. Since 1.33, 'match-whole' is implied, and 'linked' has been removed.
Returns
string

Definition at line 181 of file DateFormatter.php.

References $source, and Html\rawElement().


The documentation for this class was generated from the following file: