Skip to content

Instantly share code, notes, and snippets.

@rang501
Last active October 18, 2016 11:54
Show Gist options
  • Save rang501/bc08b936ff62fc6096cea6a77002cec6 to your computer and use it in GitHub Desktop.
Save rang501/bc08b936ff62fc6096cea6a77002cec6 to your computer and use it in GitHub Desktop.
Get correct time from datetime field (D8)
<?php
$date = DrupalDateTime::createFromFormat(DATETIME_DATETIME_STORAGE_FORMAT, 'datetime string', DATETIME_STORAGE_TIMEZONE);
$date->setTimeZone(new DateTimeZone(drupal_get_user_timezone()));
$date->format('d.m.Y H:i');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment