You are here

public static function DateTimePlus::createFromDateTime in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Component/Datetime/DateTimePlus.php \Drupal\Component\Datetime\DateTimePlus::createFromDateTime()

Creates a date object from an input date object.

Parameters

\DateTime $datetime: A DateTime object.

array $settings: @see __construct()

1 call to DateTimePlus::createFromDateTime()
DateTimePlusTest::testDateTimezoneWithDateTimeObject in core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php
Test that DrupalDateTime can detect the right timezone to use when constructed from a datetime object.

File

core/lib/Drupal/Component/Datetime/DateTimePlus.php, line 112
Contains \Drupal\Component\Datetime\DateTimePlus.

Class

DateTimePlus
Wraps DateTime().

Namespace

Drupal\Component\Datetime

Code

public static function createFromDateTime(\DateTime $datetime, $settings = array()) {
  return new static($datetime
    ->format(static::FORMAT), $datetime
    ->getTimezone(), $settings);
}