Created
February 21, 2017 14:21
-
-
Save zerolab/09f8086ddc324ac220bb943b2716e0c6 to your computer and use it in GitHub Desktop.
A set of Drupal 8 snippets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// if you have an account object ($user), then you can use $user->getTimezone(). | |
$timezone = \Drupal::currentUser()->getTimezone(); | |
$given = new \Drupal\Core\Datetime\DrupalDateTime("2016-08-01T12:30:00", $timezone); | |
$given->setTimezone(new \DateTimeZone("UTC")); | |
print $given->format("Y-m-d\Th:i:s"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment