« DateTime::createFromImmutable
DateTime::createFromTimestamp »

DateTime::createFromInterface

(PHP 8)

DateTime::createFromInterface — 指定された DateTimeInterface オブジェクトをカプセル化した、新しい DateTime オブジェクトを返す

説明

public static function DateTime::createFromInterface(DateTimeInterface $object): DateTime

パラメータ

object

変更可能なバージョンに変換する DateTimeInterface オブジェクト。 このオブジェクトは変更されませんが、 同じ日付、時刻、タイムゾーンの情報が入った新しい DateTime オブジェクトが作成されます。

戻り値

新しいDateTime クラスのインスタンスを返します。

例

例1 変更可能な DateTime オブジェクトを作る

<?php
$date = new DateTimeImmutable("2014-06-20 11:45 Europe/London");
$mutable = DateTime::createFromInterface($date);

$date = new DateTime("2014-06-20 11:45 Europe/London");
$also_mutable = DateTime::createFromInterface($date);

関連キーワード:
DateTime   DateTimeInterface   createFromInterface   date   カプセル化   Europe   London   mutable   createFromImmutable   createFromTimestamp   static   日付   時刻   タイムゾーン   インスタンス   DateTimeImmutable   also
関連する関数・ページ:
datetime.createfromimmutable   class.datetime   datetimeimmutable.createfrominterface   function.date-create   function.date-add   function.date-sub