You are here

public function Promotion::setEndDate in Commerce Core 8.2

Sets the promotion end date/time.

Parameters

\Drupal\Core\Datetime\DrupalDateTime $end_date: The promotion end date/time.

Return value

$this

Overrides PromotionInterface::setEndDate

File

modules/promotion/src/Entity/Promotion.php, line 447

Class

Promotion
Defines the promotion entity class.

Namespace

Drupal\commerce_promotion\Entity

Code

public function setEndDate(DrupalDateTime $end_date = NULL) {
  $this
    ->get('end_date')->value = NULL;
  if ($end_date) {
    $this
      ->get('end_date')->value = $end_date
      ->format(DateTimeItemInterface::DATETIME_STORAGE_FORMAT);
  }
}