function Datetime::formatExample

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Datetime/Element/Datetime.php \Drupal\Core\Datetime\Element\Datetime::formatExample()
  2. 8.9.x core/lib/Drupal/Core/Datetime/Element/Datetime.php \Drupal\Core\Datetime\Element\Datetime::formatExample()

Creates an example for a date format.

This is centralized for a consistent method of creating these examples.

Parameters

string $format: The date format.

Return value

string

Deprecated

in drupal:10.2.0 and is removed from drupal:11.0.0. There is no replacement.

See also

https://www.drupal.org/node/3385058

File

core/lib/Drupal/Core/Datetime/Element/Datetime.php, line 393

Class

Datetime
Provides a datetime element.

Namespace

Drupal\Core\Datetime\Element

Code

public static function formatExample($format) {
    @trigger_error(__METHOD__ . ' is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. There is no replacement. See https://www.drupal.org/node/3385058', E_USER_DEPRECATED);
    if (!static::$dateExample) {
        static::$dateExample = new DrupalDateTime();
    }
    return static::$dateExample->format($format);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.