You are here

public function Promotion::getEndDate in Commerce Core 8.2

Gets the promotion end date/time.

The end date/time should always be used in the store timezone. Since the promotion can belong to multiple stores, the timezone isn't known at load/save time, and is provided by the caller instead.

Note that the returned date/time value is the same in any timezone, the "2019-10-17 11:00" stored value is returned as "2019-10-17 11:00 CET" for "Europe/Berlin" and "2019-10-17 11:00 ET" for "America/New_York".

Parameters

string $store_timezone: The store timezone. E.g. "Europe/Berlin".

Return value

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

Overrides PromotionInterface::getEndDate

1 call to Promotion::getEndDate()
Promotion::available in modules/promotion/src/Entity/Promotion.php
Checks whether the promotion is available for the given order.

File

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

Class

Promotion
Defines the promotion entity class.

Namespace

Drupal\commerce_promotion\Entity

Code

public function getEndDate($store_timezone = 'UTC') {
  if (!$this
    ->get('end_date')
    ->isEmpty()) {
    return new DrupalDateTime($this
      ->get('end_date')->value, $store_timezone);
  }
}