Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. DateTimePlus.php

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.

File

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

Class

DateTimePlus
Wraps DateTime().

Namespace

Drupal\Component\Datetime

Code

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

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal