<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/class.datetimeimmutable.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'en',
  ),
  'this' => 
  array (
    0 => 'datetimeimmutable.createfrominterface.php',
    1 => 'DateTimeImmutable::createFromInterface',
    2 => 'Returns new DateTimeImmutable object encapsulating the given DateTimeInterface object',
  ),
  'up' => 
  array (
    0 => 'class.datetimeimmutable.php',
    1 => 'DateTimeImmutable',
  ),
  'prev' => 
  array (
    0 => 'datetimeimmutable.createfromformat.php',
    1 => 'DateTimeImmutable::createFromFormat',
  ),
  'next' => 
  array (
    0 => 'datetimeimmutable.createfrommutable.php',
    1 => 'DateTimeImmutable::createFromMutable',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/datetime/datetimeimmutable/createfrominterface.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="datetimeimmutable.createfrominterface" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">DateTimeImmutable::createFromInterface</h1>
  <p class="verinfo">(PHP 8)</p><p class="refpurpose"><span class="refname">DateTimeImmutable::createFromInterface</span> &mdash; <span class="dc-title">Returns new DateTimeImmutable object encapsulating the given DateTimeInterface object</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-datetimeimmutable.createfrominterface-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="modifier">static</span> <span class="methodname"><strong>DateTimeImmutable::createFromInterface</strong></span>(<span class="methodparam"><span class="type"><a href="class.datetimeinterface.php" class="type DateTimeInterface">DateTimeInterface</a></span> <code class="parameter">$object</code></span>): <span class="type"><a href="class.datetimeimmutable.php" class="type DateTimeImmutable">DateTimeImmutable</a></span></div>

 </div>


 <div class="refsect1 parameters" id="refsect1-datetimeimmutable.createfrominterface-parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">object</code></dt>
     <dd>
      <p class="para">
       The <span class="classname"><a href="class.datetimeinterface.php" class="classname">DateTimeInterface</a></span> object that needs
       to be converted to an immutable version. This object is not modified, but
       instead a new <span class="classname"><a href="class.datetimeimmutable.php" class="classname">DateTimeImmutable</a></span> object is
       created containing the same date, time, and timezone information.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-datetimeimmutable.createfrominterface-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns a new <span class="classname"><a href="class.datetimeimmutable.php" class="classname">DateTimeImmutable</a></span> instance.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-datetimeimmutable.createfrominterface-examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Example #1 Creating an immutable date time object</strong></p>
    <div class="example-contents">
<div class="annotation-non-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$date </span><span style="color: #007700">= new </span><span style="color: #0000BB">DateTime</span><span style="color: #007700">(</span><span style="color: #DD0000">"2014-06-20 11:45 Europe/London"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$immutable </span><span style="color: #007700">= </span><span style="color: #0000BB">DateTimeImmutable</span><span style="color: #007700">::</span><span style="color: #0000BB">createFromInterface</span><span style="color: #007700">(</span><span style="color: #0000BB">$date</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$date </span><span style="color: #007700">= new </span><span style="color: #0000BB">DateTimeImmutable</span><span style="color: #007700">(</span><span style="color: #DD0000">"2014-06-20 11:45 Europe/London"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$also_immutable </span><span style="color: #007700">= </span><span style="color: #0000BB">DateTimeImmutable</span><span style="color: #007700">::</span><span style="color: #0000BB">createFromInterface</span><span style="color: #007700">(</span><span style="color: #0000BB">$date</span><span style="color: #007700">);</span></span></code></div>
    </div>

   </div>
  </p>
 </div>

</div><?php manual_footer($setup); ?>