<?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 => 'fr',
  ),
  'this' => 
  array (
    0 => 'class.datetimeimmutable.php',
    1 => 'DateTimeImmutable',
    2 => 'La classe DateTimeImmutable',
  ),
  'up' => 
  array (
    0 => 'book.datetime.php',
    1 => 'Date/Heure',
  ),
  'prev' => 
  array (
    0 => 'datetime.sub.php',
    1 => 'DateTime::sub',
  ),
  'next' => 
  array (
    0 => 'datetimeimmutable.add.php',
    1 => 'DateTimeImmutable::add',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'fr',
    '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">La classe DateTimeImmutable</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">Introduction</h2>
   <p class="para">
    Représentation d&#039;une date et heure.
   </p>
   <p class="para">
    Cette classe se comporte de manière identique à
    <span class="classname"><a href="class.datetime.php" class="classname">DateTime</a></span> à l&#039;exception que de nouveaux objets sont
    retournés quand des méthodes de modification telle que
    <span class="function"><a href="datetime.modify.php" class="function">DateTime::modify()</a></span> sont appelées.
   </p>
  </div>


  <div class="section" id="datetimeimmutable.synopsis">
   <h2 class="title">Synopsis de la 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">/* Constantes héritées */</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">/* Méthodes */</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">Historique</h2>
   <p class="para">
    <table class="doctable informaltable">
     
      <thead>
       <tr>
        <th>Version</th>
        <th>Description</th>
       </tr>

      </thead>

      <tbody class="tbody">
       <tr>
        <td>8.4.0</td>
        <td>
         Les constantes de classe sont maintenant typées.
        </td>
       </tr>

       <tr>
        <td>7.1.0</td>
        <td>
         Le constructeur <span class="classname"><strong class="classname">DateTimeImmutable</strong></span> inclut désormais
         les microsecondes actuelles dans la valeur construite.
         Avant cela, il initialisait toujours les microsecondes à <code class="literal">0</code>.
        </td>
       </tr>

      </tbody>
     
    </table>

   </p>
  </div>

 </div>

 




















































































<h2>Sommaire</h2><ul class="chunklist chunklist_reference"><li><a href="datetimeimmutable.add.php">DateTimeImmutable::add</a> — Retourne un nouvel objet, avec le nombre de jours, mois, ann&eacute;es, heures, minutes et secondes ajout&eacute;</li><li><a href="datetimeimmutable.construct.php">DateTimeImmutable::__construct</a> — Retourne un nouvel objet DateTimeImmutable</li><li><a href="datetimeimmutable.createfromformat.php">DateTimeImmutable::createFromFormat</a> — Analyse une heure au format texte selon le format sp&eacute;cifi&eacute;.</li><li><a href="datetimeimmutable.createfrominterface.php">DateTimeImmutable::createFromInterface</a> — Retourne un nouvel objet DateTimeImmutable encapsulant l'objet DateTimeInterface fourni</li><li><a href="datetimeimmutable.createfrommutable.php">DateTimeImmutable::createFromMutable</a> — Retourne une nouvelle instance de DateTimeImmutable encapsulant l'objet DateTime fourni</li><li><a href="datetimeimmutable.getlasterrors.php">DateTimeImmutable::getLastErrors</a> — Retourne les alertes et erreurs</li><li><a href="datetimeimmutable.modify.php">DateTimeImmutable::modify</a> — Cr&eacute;e un nouvel objet avec l'horodatage modifi&eacute;</li><li><a href="datetimeimmutable.set-state.php">DateTimeImmutable::__set_state</a> — Le gestionnaire __set_state</li><li><a href="datetimeimmutable.setdate.php">DateTimeImmutable::setDate</a> — D&eacute;finit la date</li><li><a href="datetimeimmutable.setisodate.php">DateTimeImmutable::setISODate</a> — D&eacute;finit la date ISO</li><li><a href="datetimeimmutable.settime.php">DateTimeImmutable::setTime</a> — D&eacute;finit l'horaire</li><li><a href="datetimeimmutable.settimestamp.php">DateTimeImmutable::setTimestamp</a> — D&eacute;finit la date et l'heure bas&eacute; sur un horodatage Unix</li><li><a href="datetimeimmutable.settimezone.php">DateTimeImmutable::setTimezone</a> — D&eacute;finit le fuseau horaire</li><li><a href="datetimeimmutable.sub.php">DateTimeImmutable::sub</a> — Soustrait un nombre de jours, mois, ann&eacute;es, heures et secondes</li></ul>
</div>
<?php manual_footer($setup); ?>