<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/book.datetime.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'it',
  ),
  'this' => 
  array (
    0 => 'class.datetimeimmutable.php',
    1 => 'DateTimeImmutable',
    2 => 'The DateTimeImmutable class',
  ),
  'up' => 
  array (
    0 => 'book.datetime.php',
    1 => 'Date/Time',
  ),
  'prev' => 
  array (
    0 => 'datetime.sub.php',
    1 => 'DateTime::sub',
  ),
  'next' => 
  array (
    0 => 'datetimeimmutable.add.php',
    1 => 'DateTimeImmutable::add',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/datetime/datetimeimmutable.xml',
  ),
  'history' => 
  array (
  ),
  'extra_header_links' => 
  array (
    'rel' => 'alternate',
    'href' => '/manual/en/feeds/class.datetimeimmutable.atom',
    'type' => 'application/atom+xml',
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="class.datetimeimmutable" class="reference">

 <h1 class="title">The DateTimeImmutable class</h1>
 

 <div class="partintro"><p class="verinfo">(PHP 5 &gt;= 5.5.0, PHP 7, PHP 8)</p>


  <div class="section" id="datetimeimmutable.intro">
   <h2 class="title">Introduzione</h2>
   <p class="para">
    Representation of date and time.
   </p>
   <p class="para">
    This class behaves the same as <span class="classname"><a href="class.datetime.php" class="classname">DateTime</a></span>
    except new objects are returned when modification methods such as
    <span class="function"><a href="datetime.modify.php" class="function">DateTime::modify()</a></span> are called.
   </p>
  </div>


  <div class="section" id="datetimeimmutable.synopsis">
   <h2 class="title">Sommario della classe</h2>


   <div class="classsynopsis"><div class="classsynopsisinfo">
    
     <span class="modifier">class</span> <strong class="classname"><strong class="classname">DateTimeImmutable</strong></strong>
    

    
     <span class="modifier">implements</span>
      <a href="class.datetimeinterface.php" class="interfacename">DateTimeInterface</a> {</div>

    <div class="classsynopsisinfo classsynopsisinfo_comment">/* Costanti ereditate */</div>
    <div class="fieldsynopsis">
     <span class="modifier">public</span>
     <span class="modifier">const</span>
     <span class="type"><a href="language.types.string.php" class="type string">string</a></span>
      <var class="fieldsynopsis_varname"><a href="class.datetimeinterface.php#datetimeinterface.constants.atom"><var class="varname">DateTimeInterface::ATOM</var></a></var><span class="initializer"> = &quot;Y-m-d\\TH:i:sP&quot;</span>;</div>
<div class="fieldsynopsis"><span class="modifier">public</span>
     <span class="modifier">const</span>
     <span class="type"><a href="language.types.string.php" class="type string">string</a></span>
      <var class="fieldsynopsis_varname"><a href="class.datetimeinterface.php#datetimeinterface.constants.cookie"><var class="varname">DateTimeInterface::COOKIE</var></a></var><span class="initializer"> = &quot;l, d-M-Y H:i:s T&quot;</span>;</div>
<div class="fieldsynopsis"><span class="modifier">public</span>
     <span class="modifier">const</span>
     <span class="type"><a href="language.types.string.php" class="type string">string</a></span>
      <var class="fieldsynopsis_varname"><a href="class.datetimeinterface.php#datetimeinterface.constants.iso8601"><var class="varname">DateTimeInterface::ISO8601</var></a></var><span class="initializer"> = &quot;Y-m-d\\TH:i:sO&quot;</span>;</div>
<div class="fieldsynopsis"><span class="modifier">public</span>
     <span class="modifier">const</span>
     <span class="type"><a href="language.types.string.php" class="type string">string</a></span>
      <var class="fieldsynopsis_varname"><a href="class.datetimeinterface.php#datetimeinterface.constants.iso8601-expanded"><var class="varname">DateTimeInterface::ISO8601_EXPANDED</var></a></var><span class="initializer"> = &quot;X-m-d\\TH:i:sP&quot;</span>;</div>
<div class="fieldsynopsis"><span class="modifier">public</span>
     <span class="modifier">const</span>
     <span class="type"><a href="language.types.string.php" class="type string">string</a></span>
      <var class="fieldsynopsis_varname"><a href="class.datetimeinterface.php#datetimeinterface.constants.rfc822"><var class="varname">DateTimeInterface::RFC822</var></a></var><span class="initializer"> = &quot;D, d M y H:i:s O&quot;</span>;</div>
<div class="fieldsynopsis"><span class="modifier">public</span>
     <span class="modifier">const</span>
     <span class="type"><a href="language.types.string.php" class="type string">string</a></span>
      <var class="fieldsynopsis_varname"><a href="class.datetimeinterface.php#datetimeinterface.constants.rfc850"><var class="varname">DateTimeInterface::RFC850</var></a></var><span class="initializer"> = &quot;l, d-M-y H:i:s T&quot;</span>;</div>
<div class="fieldsynopsis"><span class="modifier">public</span>
     <span class="modifier">const</span>
     <span class="type"><a href="language.types.string.php" class="type string">string</a></span>
      <var class="fieldsynopsis_varname"><a href="class.datetimeinterface.php#datetimeinterface.constants.rfc1036"><var class="varname">DateTimeInterface::RFC1036</var></a></var><span class="initializer"> = &quot;D, d M y H:i:s O&quot;</span>;</div>
<div class="fieldsynopsis"><span class="modifier">public</span>
     <span class="modifier">const</span>
     <span class="type"><a href="language.types.string.php" class="type string">string</a></span>
      <var class="fieldsynopsis_varname"><a href="class.datetimeinterface.php#datetimeinterface.constants.rfc1123"><var class="varname">DateTimeInterface::RFC1123</var></a></var><span class="initializer"> = &quot;D, d M Y H:i:s O&quot;</span>;</div>
<div class="fieldsynopsis"><span class="modifier">public</span>
     <span class="modifier">const</span>
     <span class="type"><a href="language.types.string.php" class="type string">string</a></span>
      <var class="fieldsynopsis_varname"><a href="class.datetimeinterface.php#datetimeinterface.constants.rfc7231"><var class="varname">DateTimeInterface::RFC7231</var></a></var><span class="initializer"> = &quot;D, d M Y H:i:s \\G\\M\\T&quot;</span>;</div>
<div class="fieldsynopsis"><span class="modifier">public</span>
     <span class="modifier">const</span>
     <span class="type"><a href="language.types.string.php" class="type string">string</a></span>
      <var class="fieldsynopsis_varname"><a href="class.datetimeinterface.php#datetimeinterface.constants.rfc2822"><var class="varname">DateTimeInterface::RFC2822</var></a></var><span class="initializer"> = &quot;D, d M Y H:i:s O&quot;</span>;</div>
<div class="fieldsynopsis"><span class="modifier">public</span>
     <span class="modifier">const</span>
     <span class="type"><a href="language.types.string.php" class="type string">string</a></span>
      <var class="fieldsynopsis_varname"><a href="class.datetimeinterface.php#datetimeinterface.constants.rfc3339"><var class="varname">DateTimeInterface::RFC3339</var></a></var><span class="initializer"> = &quot;Y-m-d\\TH:i:sP&quot;</span>;</div>
<div class="fieldsynopsis"><span class="modifier">public</span>
     <span class="modifier">const</span>
     <span class="type"><a href="language.types.string.php" class="type string">string</a></span>
      <var class="fieldsynopsis_varname"><a href="class.datetimeinterface.php#datetimeinterface.constants.rfc3339-extended"><var class="varname">DateTimeInterface::RFC3339_EXTENDED</var></a></var><span class="initializer"> = &quot;Y-m-d\\TH:i:s.vP&quot;</span>;</div>
<div class="fieldsynopsis"><span class="modifier">public</span>
     <span class="modifier">const</span>
     <span class="type"><a href="language.types.string.php" class="type string">string</a></span>
      <var class="fieldsynopsis_varname"><a href="class.datetimeinterface.php#datetimeinterface.constants.rss"><var class="varname">DateTimeInterface::RSS</var></a></var><span class="initializer"> = &quot;D, d M Y H:i:s O&quot;</span>;</div>
<div class="fieldsynopsis"><span class="modifier">public</span>
     <span class="modifier">const</span>
     <span class="type"><a href="language.types.string.php" class="type string">string</a></span>
      <var class="fieldsynopsis_varname"><a href="class.datetimeinterface.php#datetimeinterface.constants.w3c"><var class="varname">DateTimeInterface::W3C</var></a></var><span class="initializer"> = &quot;Y-m-d\\TH:i:sP&quot;</span>;</div>


    <div class="classsynopsisinfo classsynopsisinfo_comment">/* Metodi */</div>
    <div class="constructorsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><a href="datetimeimmutable.construct.php" class="methodname">__construct</a></span>(<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$datetime</code><span class="initializer"> = &quot;now&quot;</span></span>, <span class="methodparam"><span class="type"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="class.datetimezone.php" class="type DateTimeZone">DateTimeZone</a></span></span> <code class="parameter">$timezone</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span>)</div>

    <div class="methodsynopsis dc-description"><span class="attribute"><a href="class.nodiscard.php">#[\NoDiscard]</a> </span><br>
   <span class="modifier">public</span> <span class="methodname"><a href="datetimeimmutable.add.php" class="methodname">add</a></span>(<span class="methodparam"><span class="type"><a href="class.dateinterval.php" class="type DateInterval">DateInterval</a></span> <code class="parameter">$interval</code></span>): <span class="type"><a href="class.datetimeimmutable.php" class="type DateTimeImmutable">DateTimeImmutable</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="modifier">static</span> <span class="methodname"><a href="datetimeimmutable.createfromformat.php" class="methodname">createFromFormat</a></span>(<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$format</code></span>, <span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$datetime</code></span>, <span class="methodparam"><span class="type"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="class.datetimezone.php" class="type DateTimeZone">DateTimeZone</a></span></span> <code class="parameter">$timezone</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span>): <span class="type"><span class="type"><a href="class.datetimeimmutable.php" class="type DateTimeImmutable">DateTimeImmutable</a></span>|<span class="type"><a href="language.types.singleton.php" class="type false">false</a></span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="modifier">static</span> <span class="methodname"><a href="datetimeimmutable.createfrominterface.php" class="methodname">createFromInterface</a></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 class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="modifier">static</span> <span class="methodname"><a href="datetimeimmutable.createfrommutable.php" class="methodname">createFromMutable</a></span>(<span class="methodparam"><span class="type"><a href="class.datetime.php" class="type DateTime">DateTime</a></span> <code class="parameter">$object</code></span>): <span class="type">static</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="modifier">static</span> <span class="methodname"><a href="datetimeimmutable.getlasterrors.php" class="methodname">getLastErrors</a></span>(): <span class="type"><span class="type"><a href="language.types.array.php" class="type array">array</a></span>|<span class="type"><a href="language.types.singleton.php" class="type false">false</a></span></span></div>
<div class="methodsynopsis dc-description"><span class="attribute"><a href="class.nodiscard.php">#[\NoDiscard]</a> </span><br>
   <span class="modifier">public</span> <span class="methodname"><a href="datetimeimmutable.modify.php" class="methodname">modify</a></span>(<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$modifier</code></span>): <span class="type"><a href="class.datetimeimmutable.php" class="type DateTimeImmutable">DateTimeImmutable</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="modifier">static</span> <span class="methodname"><a href="datetimeimmutable.set-state.php" class="methodname">__set_state</a></span>(<span class="methodparam"><span class="type"><a href="language.types.array.php" class="type array">array</a></span> <code class="parameter">$array</code></span>): <span class="type"><a href="class.datetimeimmutable.php" class="type DateTimeImmutable">DateTimeImmutable</a></span></div>
<div class="methodsynopsis dc-description"><span class="attribute"><a href="class.nodiscard.php">#[\NoDiscard]</a> </span><br>
   <span class="modifier">public</span> <span class="methodname"><a href="datetimeimmutable.setdate.php" class="methodname">setDate</a></span>(<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$year</code></span>, <span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$month</code></span>, <span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$day</code></span>): <span class="type"><a href="class.datetimeimmutable.php" class="type DateTimeImmutable">DateTimeImmutable</a></span></div>
<div class="methodsynopsis dc-description"><span class="attribute"><a href="class.nodiscard.php">#[\NoDiscard]</a> </span><br>
   <span class="modifier">public</span> <span class="methodname"><a href="datetimeimmutable.setisodate.php" class="methodname">setISODate</a></span>(<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$year</code></span>, <span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$week</code></span>, <span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$dayOfWeek</code><span class="initializer"> = 1</span></span>): <span class="type"><a href="class.datetimeimmutable.php" class="type DateTimeImmutable">DateTimeImmutable</a></span></div>
<div class="methodsynopsis dc-description"><span class="attribute"><a href="class.nodiscard.php">#[\NoDiscard]</a> </span><br>
   <span class="modifier">public</span> <span class="methodname"><a href="datetimeimmutable.settime.php" class="methodname">setTime</a></span>(<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$hour</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$minute</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$second</code><span class="initializer"> = 0</span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$microsecond</code><span class="initializer"> = 0</span></span><br>): <span class="type"><a href="class.datetimeimmutable.php" class="type DateTimeImmutable">DateTimeImmutable</a></span></div>
<div class="methodsynopsis dc-description"><span class="attribute"><a href="class.nodiscard.php">#[\NoDiscard]</a> </span><br>
   <span class="modifier">public</span> <span class="methodname"><a href="datetimeimmutable.settimestamp.php" class="methodname">setTimestamp</a></span>(<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$timestamp</code></span>): <span class="type"><a href="class.datetimeimmutable.php" class="type DateTimeImmutable">DateTimeImmutable</a></span></div>
<div class="methodsynopsis dc-description"><span class="attribute"><a href="class.nodiscard.php">#[\NoDiscard]</a> </span><br>
   <span class="modifier">public</span> <span class="methodname"><a href="datetimeimmutable.settimezone.php" class="methodname">setTimezone</a></span>(<span class="methodparam"><span class="type"><a href="class.datetimezone.php" class="type DateTimeZone">DateTimeZone</a></span> <code class="parameter">$timezone</code></span>): <span class="type"><a href="class.datetimeimmutable.php" class="type DateTimeImmutable">DateTimeImmutable</a></span></div>
<div class="methodsynopsis dc-description"><span class="attribute"><a href="class.nodiscard.php">#[\NoDiscard]</a> </span><br>
   <span class="modifier">public</span> <span class="methodname"><a href="datetimeimmutable.sub.php" class="methodname">sub</a></span>(<span class="methodparam"><span class="type"><a href="class.dateinterval.php" class="type DateInterval">DateInterval</a></span> <code class="parameter">$interval</code></span>): <span class="type"><a href="class.datetimeimmutable.php" class="type DateTimeImmutable">DateTimeImmutable</a></span></div>

    <div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="datetime.diff.php" class="methodname">diff</a></span>(<span class="methodparam"><span class="type"><a href="class.datetimeinterface.php" class="type DateTimeInterface">DateTimeInterface</a></span> <code class="parameter">$targetObject</code></span>, <span class="methodparam"><span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span> <code class="parameter">$absolute</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong></span></span>): <span class="type"><a href="class.dateinterval.php" class="type DateInterval">DateInterval</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="datetime.format.php" class="methodname">format</a></span>(<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$format</code></span>): <span class="type"><a href="language.types.string.php" class="type string">string</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="datetime.getoffset.php" class="methodname">getOffset</a></span>(): <span class="type"><a href="language.types.integer.php" class="type int">int</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="datetime.gettimestamp.php" class="methodname">getTimestamp</a></span>(): <span class="type"><a href="language.types.integer.php" class="type int">int</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="datetime.gettimezone.php" class="methodname">getTimezone</a></span>(): <span class="type"><span class="type"><a href="class.datetimezone.php" class="type DateTimeZone">DateTimeZone</a></span>|<span class="type"><a href="language.types.singleton.php" class="type false">false</a></span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="datetime.serialize.php" class="methodname">__serialize</a></span>(): <span class="type"><a href="language.types.array.php" class="type array">array</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="datetime.unserialize.php" class="methodname">__unserialize</a></span>(<span class="methodparam"><span class="type"><a href="language.types.array.php" class="type array">array</a></span> <code class="parameter">$data</code></span>): <span class="type"><a href="language.types.void.php" class="type void">void</a></span></div>
<div class="methodsynopsis dc-description"><span class="attribute"><a href="class.deprecated.php">#[\Deprecated]</a> </span><br>
   <span class="modifier">public</span> <span class="methodname"><a href="datetime.wakeup.php" class="methodname">__wakeup</a></span>(): <span class="type"><a href="language.types.void.php" class="type void">void</a></span></div>

   }</div>


  </div>

 <div class="section" id="datetimeimmutable.changelog">
  <h2 class="title">Log delle modifiche</h2>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>Versione</th>
       <th>Descrizione</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>8.4.0</td>
       <td>
        The class constants are now typed.
       </td>
      </tr>

      <tr>
       <td>7.1.0</td>
       <td>
        The <span class="classname"><strong class="classname">DateTimeImmutable</strong></span> constructor now includes the
        current microseconds in the constructed value. Before this, it would
        always initialise the microseconds to <code class="literal">0</code>.
       </td>
      </tr>

     </tbody>
    
   </table>

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

 






































































<h2>Indice dei contenuti</h2><ul class="chunklist chunklist_reference"><li><a href="datetimeimmutable.add.php">DateTimeImmutable::add</a> — Returns a new object, with added amount of days, months, years, hours, minutes and seconds</li><li><a href="datetimeimmutable.construct.php">DateTimeImmutable::__construct</a> — Returns new DateTimeImmutable object</li><li><a href="datetimeimmutable.createfromformat.php">DateTimeImmutable::createFromFormat</a> — Parses a time string according to a specified format</li><li><a href="datetimeimmutable.createfrominterface.php">DateTimeImmutable::createFromInterface</a> — Returns new DateTimeImmutable object encapsulating the given DateTimeInterface object</li><li><a href="datetimeimmutable.createfrommutable.php">DateTimeImmutable::createFromMutable</a> — Returns new DateTimeImmutable instance encapsulating the given DateTime object</li><li><a href="datetimeimmutable.getlasterrors.php">DateTimeImmutable::getLastErrors</a> — Returns the warnings and errors</li><li><a href="datetimeimmutable.modify.php">DateTimeImmutable::modify</a> — Creates a new object with modified timestamp</li><li><a href="datetimeimmutable.set-state.php">DateTimeImmutable::__set_state</a> — The __set_state handler</li><li><a href="datetimeimmutable.setdate.php">DateTimeImmutable::setDate</a> — Sets the date</li><li><a href="datetimeimmutable.setisodate.php">DateTimeImmutable::setISODate</a> — Sets the ISO date</li><li><a href="datetimeimmutable.settime.php">DateTimeImmutable::setTime</a> — Sets the time</li><li><a href="datetimeimmutable.settimestamp.php">DateTimeImmutable::setTimestamp</a> — Sets the date and time based on a Unix timestamp</li><li><a href="datetimeimmutable.settimezone.php">DateTimeImmutable::setTimezone</a> — Sets the time zone</li><li><a href="datetimeimmutable.sub.php">DateTimeImmutable::sub</a> — Subtracts an amount of days, months, years, hours, minutes and seconds</li></ul>
</div>
<?php manual_footer($setup); ?>