public static function DateTimePlus::createFromDateTime

public static DateTimePlus::createFromDateTime(\DateTime $datetime, $settings = array())

Creates a date object from an input date object.

Parameters

\DateTime $datetime: A DateTime object.

array $settings: @see __construct()

Return value

static A new DateTimePlus object.

File

core/lib/Drupal/Component/Datetime/DateTimePlus.php, line 111

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

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Component!Datetime!DateTimePlus.php/function/DateTimePlus::createFromDateTime/8.1.x