function DateTimePlus::createFromDateTime
Creates a date object from an input date object.
Parameters
\DateTimeInterface $datetime: A DateTime object.
array $settings: (optional) A keyed array for settings, suitable for passing on to __construct().
Return value
static A new DateTimePlus object.
1 call to DateTimePlus::createFromDateTime()
- DateTimePlusTest::testDateTimezoneWithDateTimeObject in core/
tests/ Drupal/ Tests/ Component/ Datetime/ DateTimePlusTest.php  - Tests that DrupalDateTime can detect the correct timezone to use.
 
File
- 
              core/
lib/ Drupal/ Component/ Datetime/ DateTimePlus.php, line 88  
Class
- DateTimePlus
 - Wraps DateTime().
 
Namespace
Drupal\Component\DatetimeCode
public static function createFromDateTime(\DateTimeInterface $datetime, $settings = []) {
  return new static($datetime->format(static::FORMAT), $datetime->getTimezone(), $settings);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.