Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions
Date Class Reference

Public Member Functions

 __construct (DateTime $dateTime, TimezoneInterface $localeDate, ScopeConfigInterface $scopeConfig)
 
 formatDate ($storeId, $date=null)
 

Detailed Description

Definition at line 12 of file Date.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( DateTime  $dateTime,
TimezoneInterface  $localeDate,
ScopeConfigInterface  $scopeConfig 
)

Construct

Parameters
DateTime$dateTime
TimezoneInterface$localeDate
ScopeConfigInterface$scopeConfig

Definition at line 36 of file Date.php.

40  {
41  $this->dateTime = $dateTime;
42  $this->localeDate = $localeDate;
43  $this->scopeConfig = $scopeConfig;
44  }

Member Function Documentation

◆ formatDate()

formatDate (   $storeId,
  $date = null 
)

Retrieve date value in elasticsearch format (ISO 8601) Example: 1995-12-31T23:59:59

Parameters
int$storeId
string | null$date
Returns
string|null @SuppressWarnings(PHPMD.UnusedFormalParameter)

Definition at line 55 of file Date.php.

56  {
57  if ($this->dateTime->isEmptyDate($date)) {
58  return null;
59  }
60  $dateObj = new \DateTime($date, new \DateTimeZone('UTC'));
61  return $dateObj->format('c');
62  }

The documentation for this class was generated from the following file: