private function ScheduledPublishGenericFormatter::parseDate in Scheduled Publish 8.3
Same name and namespace in other branches
- 8.2 src/Plugin/Field/FieldFormatter/ScheduledPublishGenericFormatter.php \Drupal\scheduled_publish\Plugin\Field\FieldFormatter\ScheduledPublishGenericFormatter::parseDate()
Parameters
string $strDateTime:
string $strDateFormat:
Return value
\DateTime
Throws
\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
\Drupal\Component\Plugin\Exception\PluginNotFoundException
1 call to ScheduledPublishGenericFormatter::parseDate()
- ScheduledPublishGenericFormatter::parseData in src/
Plugin/ Field/ FieldFormatter/ ScheduledPublishGenericFormatter.php
File
- src/
Plugin/ Field/ FieldFormatter/ ScheduledPublishGenericFormatter.php, line 203
Class
- ScheduledPublishGenericFormatter
- Plugin implementation of the 'scheduled_publish_generic_formatter' formatter.
Namespace
Drupal\scheduled_publish\Plugin\Field\FieldFormatterCode
private function parseDate(string $strDateTime, string $strDateFormat) : string {
$dateFormat = $this->entityTypeManager
->getStorage('date_format')
->load($strDateFormat);
if ($dateFormat !== NULL) {
$pattern = $dateFormat
->getPattern();
$drupalDateTime = DrupalDateTime::createFromFormat(ScheduledPublish::DATETIME_STORAGE_FORMAT, $strDateTime, ScheduledPublish::STORAGE_TIMEZONE);
$drupalDateTime
->setTimezone(new \DateTimeZone(date_default_timezone_get()));
return $drupalDateTime
->format($pattern);
}
$this->logger
->error($this
->t('Date format: "' . $this
->getSetting('date_format') . '" could not be found!'));
return NULL;
}