array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'ja', ), 'this' => array ( 0 => 'datetime.createfrominterface.php', 1 => 'DateTime::createFromInterface', ), 'up' => array ( 0 => 'class.datetime.php', 1 => 'DateTime', ), 'prev' => array ( 0 => 'datetime.createfromimmutable.php', 1 => 'DateTime::createFromImmutable', ), 'next' => array ( 0 => 'datetime.getlasterrors.php', 1 => 'DateTime::getLastErrors', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'ja', 'path' => 'reference/datetime/datetime/createfrominterface.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 8)
DateTime::createFromInterface — 指定された DateTimeInterface オブジェクトをカプセル化した、新しい 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);
?>