public function NetlifyManager::formatNetlifyDateTime in Build Hooks 8.2
Same name and namespace in other branches
- 3.x 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
- Class NetlifyManager.
Namespace
Drupal\build_hooks_netlifyCode
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');
}