You are here

public function ContentHubFilter::changeDateFormatYearMonthDay2MonthDayYear in Acquia Content Hub 8

Change Date format from "Y-m-d" to "m-d-Y".

Overrides ContentHubFilterInterface::changeDateFormatYearMonthDay2MonthDayYear

File

acquia_contenthub_subscriber/src/Entity/ContentHubFilter.php, line 266

Class

ContentHubFilter
Defines the ContentHubFilter entity.

Namespace

Drupal\acquia_contenthub_subscriber\Entity

Code

public function changeDateFormatYearMonthDay2MonthDayYear() {
  if (!empty($this->from_date)) {
    if ($from_date = \DateTime::createFromFormat('Y-m-d', $this->from_date)) {
      $this->from_date = $from_date
        ->format('m-d-Y');
    }
  }
  if (!empty($this->to_date)) {
    if ($to_date = \DateTime::createFromFormat('Y-m-d', $this->to_date)) {
      $this->to_date = $to_date
        ->format('m-d-Y');
    }
  }
  return $this;
}