Same name and namespace in other branches
  1. 8.9.x core/lib/Drupal/Component/Datetime/DateTimePlus.php \Drupal\Component\Datetime\DateTimePlus::setDefaultDateTime()
  2. 9 core/lib/Drupal/Component/Datetime/DateTimePlus.php \Drupal\Component\Datetime\DateTimePlus::setDefaultDateTime()

Sets the default time for an object built from date-only data.

The default time for a date without time can be anything, so long as it is consistently applied. If we use noon, dates in most timezones will have the same value for in both the local timezone and UTC.

File

core/lib/Drupal/Component/Datetime/DateTimePlus.php, line 712

Class

DateTimePlus
Wraps DateTime().

Namespace

Drupal\Component\Datetime

Code

public function setDefaultDateTime() {
  $this->dateTimeObject
    ->setTime(12, 0, 0);
}