You are here

public function NetlifyManager::formatNetlifyDateTime in Build Hooks 3.x

Same name and namespace in other branches
  1. 8.2 modules/build_hooks_netlify/src/NetlifyManager.php \Drupal\build_hooks_netlify\NetlifyManager::formatNetlifyDateTime()

Converts the datetime format into a drupal formatted date.

Parameters

string $datetime: Date in the format returned by the Netlify api.

Return value

string Drupal formatted date.

Overrides NetlifyManagerInterface::formatNetlifyDateTime

File

modules/build_hooks_netlify/src/NetlifyManager.php, line 100

Class

NetlifyManager
Defines a manager service for netlify deployments.

Namespace

Drupal\build_hooks_netlify

Code

public function formatNetlifyDateTime($datetime) {

  // We remove the last5 digits because we can't handle milliseconds:
  $datetime_no_millis = substr($datetime, 0, -5);
  $timezone = new \DateTimeZone('UTC');
  $date = \DateTime::createFromFormat(self::NETLIFY_DATE_FORMAT, $datetime_no_millis, $timezone);
  return $this->dateFormatter
    ->format($date
    ->getTimestamp(), 'long');
}