You are here

public static function DateTimePlus::createFromDateTime in Service Container 7.2

Same name and namespace in other branches
  1. 7 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()

File

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);
}