You are here

public static function EntityShareUtility::convertChangedTime in Entity Share 8.3

Converts any expected "changed" time value into integer timestamp.

Needed mostly for converting times coming from Remotes.

Parameters

string|int $changed_time: The timestamp or formatted date of "changed" date.

Return value

int The timestamp of "changed" date.

5 calls to EntityShareUtility::convertChangedTime()
ChangedTime::processEntity in modules/entity_share_client/src/Plugin/EntityShareClient/Processor/ChangedTime.php
Method called on STAGE_PROCESS_ENTITY.
EntityParser::getRemoteChangedTime in modules/entity_share_diff/src/Service/EntityParser.php
Gets 'changed' timestamp of remote entity, if available.
MultilingualTest::overrideJsonDataAttributes in modules/entity_share_client/tests/src/Functional/MultilingualTest.php
Override attributes of entity's JSON:API data.
SkipImported::isEntityImportable in modules/entity_share_client/src/Plugin/EntityShareClient/Processor/SkipImported.php
Method called on STAGE_IS_ENTITY_IMPORTABLE.
StateInformation::getStatusInfo in modules/entity_share_client/src/Service/StateInformation.php
Check if an entity already exists or not and get status info.

File

src/EntityShareUtility.php, line 61

Class

EntityShareUtility
Contains helper methods for Entity Share.

Namespace

Drupal\entity_share

Code

public static function convertChangedTime($changed_time) {
  $entity_changed_time = 0;

  // If the website is using backward compatible timestamps output.
  // @see https://www.drupal.org/node/2859657.
  // The value is cast in integer for
  // https://www.drupal.org/node/2837696.
  if (is_numeric($changed_time)) {
    $entity_changed_time = (int) $changed_time;
  }
  else {
    $changed_datetime = \DateTime::createFromFormat(\DateTime::RFC3339, $changed_time);
    if ($changed_datetime) {
      $entity_changed_time = $changed_datetime
        ->getTimestamp();
    }
  }
  return $entity_changed_time;
}