You are here

public function SitewideAlert::getScheduledStartDateTime in Sitewide Alert 8

Gets the start date of this Sitewide Alert.

Return value

\Drupal\Core\Datetime\DrupalDateTime|null The date when this alert is scheduled to start, null otherwise;

Overrides SitewideAlertInterface::getScheduledStartDateTime

1 call to SitewideAlert::getScheduledStartDateTime()
SitewideAlert::isScheduledToShowAt in src/Entity/SitewideAlert.php
Determines if this SitewideAlert should be shown at the given time.

File

src/Entity/SitewideAlert.php, line 424

Class

SitewideAlert
Defines the Sitewide Alert entity.

Namespace

Drupal\sitewide_alert\Entity

Code

public function getScheduledStartDateTime() : ?DrupalDateTime {
  $value = $this
    ->get('scheduled_date')->value;
  if ($value === NULL || is_array($value) && (empty($value['date']) || empty($value['time']))) {
    return NULL;
  }
  return DrupalDateTime::createFromFormat(DateTimeItemInterface::DATETIME_STORAGE_FORMAT, $value, DateTimeItemInterface::STORAGE_TIMEZONE);
}