DrupalDateTime::__construct

public DrupalDateTime::__construct($time = 'now', $timezone = NULL, $settings = array())

Constructs a date object.

Parameters

string $time: A date/input_time_adjusted string. Defaults to 'now'.

mixed $timezone: PHP DateTimeZone object, string or NULL allowed. Defaults to NULL.

array $settings:

  • validate_format: (optional) Boolean choice to validate the created date using the input format. The format used in createFromFormat() allows slightly different values than format(). Using an input format that works in both functions makes it possible to a validation step to confirm that the date created from a format string exactly matches the input. This option indicates the format can be used for validation. Defaults to TRUE.
  • langcode: (optional) Used to control the result of the format() method. Defaults to NULL.
  • debug: (optional) Boolean choice to leave debug values in the date object for debugging purposes. Defaults to FALSE.

Overrides DateTimePlus::__construct

File

core/lib/Drupal/Core/Datetime/DrupalDateTime.php, line 51

Class

DrupalDateTime
Extends DateTimePlus().

Namespace

Drupal\Core\Datetime

Code

public function __construct($time = 'now', $timezone = NULL, $settings = array()) {
  if (!isset($settings['langcode'])) {
    $settings['langcode'] = \Drupal::languageManager()->getCurrentLanguage()->getId();
  }

  // Instantiate the parent class.
  parent::__construct($time, $timezone, $settings);

}
doc_Drupal
2016-10-29 09:02:53
Comments
Leave a Comment

Please login to continue.