<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.datetime.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'it',
  ),
  'this' => 
  array (
    0 => 'function.strtotime.php',
    1 => 'strtotime',
    2 => 'Analizza qualsiasi descrizione datetime testuale inglese e la converte in uno Unix timestamp',
  ),
  'up' => 
  array (
    0 => 'ref.datetime.php',
    1 => 'Date/Time Funzioni',
  ),
  'prev' => 
  array (
    0 => 'function.strptime.php',
    1 => 'strptime',
  ),
  'next' => 
  array (
    0 => 'function.time.php',
    1 => 'time',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'it',
    'path' => 'reference/datetime/functions/strtotime.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.strtotime" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">strtotime</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">strtotime</span> &mdash; <span class="dc-title">Analizza qualsiasi descrizione datetime testuale inglese e la converte in uno Unix timestamp</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.strtotime-description">
  <h3 class="title">Descrizione</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>strtotime</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$time</code></span>, <span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$now</code><span class="initializer"> = time()</span></span>): <span class="type"><a href="language.types.integer.php" class="type int">int</a></span></div>

  <p class="simpara">
   La funzione si aspetta una stringa contenente un formato di data inglese
   e proverà ad analizzare quel formato ed a convertirlo in uno Unix timestamp (il numero di
   secondi dall&#039;1 Gennaio 1970 00:00:00 UTC), relativo al timestamp dato
   in <code class="parameter">now</code>, oppure all&#039;ora corrente se
   non viene fornito <code class="parameter">now</code>.
  </p>
  <p class="para">
   Ogni parametro di questa funzione usa il fuso orario predefinito a meno che non
   sia specificato il fuso orario in quel parametro.  Badare a non usare
   diversi fusi orari in ogni parametro a meno che non sia intenzionale.
   Vedere <span class="function"><a href="function.date-default-timezone-get.php" class="function">date_default_timezone_get()</a></span> sui vari
   modi per definire il fuso orario predefinito.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.strtotime-parameters">
  <h3 class="title">Elenco dei parametri</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">time</code></dt>
     <dd>
      <p class="para">Una stringa data/ora. I formati validi sono descritti in <a href="datetime.formats.php" class="link">Formati di Data e Tempo</a>.</p>
     </dd>
    
    
     <dt><code class="parameter">now</code></dt>
     <dd>
      <p class="para">
       Il timestamp che è usato come base per il calcolo delle date
       relative.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.strtotime-returnvalues">
  <h3 class="title">Valori restituiti</h3>
  <p class="para">
   Restituisce un timestamp in caso di successo, altrimenti <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>. Prima di PHP 5.1.0,
   questa funzione restituiva <code class="literal">-1</code> in caso di fallimento.
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-function.strtotime-errors">
  <h3 class="title">Errori/Eccezioni</h3>
   
   <p class="para">
Ogni chiamata a una funzione data/ora genera un <strong><code><a href="errorfunc.constants.php#constant.e-notice">E_NOTICE</a></code></strong> 
se il time zone non è valido, e/o un messaggio <strong><code><a href="errorfunc.constants.php#constant.e-strict">E_STRICT</a></code></strong>
o <strong><code><a href="errorfunc.constants.php#constant.e-warning">E_WARNING</a></code></strong>
se si usano le impostazioni di sistema o la variabile d&#039;ambiente <var class="varname">TZ</var>.
Vedere anche <span class="function"><a href="function.date-default-timezone-set.php" class="function">date_default_timezone_set()</a></span></p>
 
 </div>


 <div class="refsect1 changelog" id="refsect1-function.strtotime-changelog">
  <h3 class="title">Log delle modifiche</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>Versione</th>
       <th>Descrizione</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>5.3.0</td>
       <td>
        Prima di PHP 5.3.0, i formati del tempo relativi forniti all&#039;argomento
        <code class="parameter">time</code> di <span class="function"><strong>strtotime()</strong></span>
        come <code class="literal">this week</code>, <code class="literal">previous week</code>,
        <code class="literal">last week</code>, e <code class="literal">next week</code> erano
        interpretati per intendere un periodo di 7 giorni relativo alla data/ora corrente, invece
        di un periodo settimanale di <code class="literal">Monday</code> a <code class="literal">Sunday</code>.
       </td>
      </tr>

      <tr>
       <td>5.3.0</td>
       <td>
        Prima di PHP 5.3.0, <code class="literal">24:00</code> non era un formato valido e
        <span class="function"><strong>strtotime()</strong></span> restituiva <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>.
       </td>
      </tr>

      <tr>
       <td>5.2.7</td>
       <td>
        In PHP 5 precedente a 5.2.7, richiedere una data occorrenza di un
        dato giorno della settimana in un mese dove il giorno della settimana era il primo giorno
        del mese aggiungerebbe in modo scorretto una settimana al timestamp
        restituito. Questo è stato corretto in 5.2.7 e nelle versioni
        successive.
       </td>
      </tr>

      <tr>
       <td>5.1.0</td>
       <td>
        Ora restituisce <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> in caso di fallimento, invece
        di <code class="literal">-1</code>.
       </td>
      </tr>


      <tr><td>5.1.0</td><td><p class="para">
Ora emette gli errori time zone <strong><code><a href="errorfunc.constants.php#constant.e-strict">E_STRICT</a></code></strong> e <strong><code><a href="errorfunc.constants.php#constant.e-notice">E_NOTICE</a></code></strong> 
</p></td></tr>


      <tr>
       <td>5.0.2</td>
       <td>
        In PHP 5 fino a 5.0.2, <code class="literal">&quot;now&quot;</code> e altri
        tempi relativi sono erroneamente calcolati a partire dalla mezzanotte
        di oggi. Questo differisce dalle altre versioni in cui viene
        correttamente calcolato dal tempo corrente.
       </td>
      </tr>

      <tr>
       <td>5.0.0</td>
       <td>
        I microsecondi hanno cominciato ad essere consentiti, ma sono ignorati.
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.strtotime-examples">
  <h3 class="title">Esempi</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Example #1 Un esempio di <span class="function"><strong>strtotime()</strong></span></strong></p>
    <div class="example-contents">
<div class="annotation-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">strtotime</span><span style="color: #007700">(</span><span style="color: #DD0000">"now"</span><span style="color: #007700">), </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br />echo </span><span style="color: #0000BB">strtotime</span><span style="color: #007700">(</span><span style="color: #DD0000">"10 September 2000"</span><span style="color: #007700">), </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br />echo </span><span style="color: #0000BB">strtotime</span><span style="color: #007700">(</span><span style="color: #DD0000">"+1 day"</span><span style="color: #007700">), </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br />echo </span><span style="color: #0000BB">strtotime</span><span style="color: #007700">(</span><span style="color: #DD0000">"+1 week"</span><span style="color: #007700">), </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br />echo </span><span style="color: #0000BB">strtotime</span><span style="color: #007700">(</span><span style="color: #DD0000">"+1 week 2 days 4 hours 2 seconds"</span><span style="color: #007700">), </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br />echo </span><span style="color: #0000BB">strtotime</span><span style="color: #007700">(</span><span style="color: #DD0000">"next Thursday"</span><span style="color: #007700">), </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br />echo </span><span style="color: #0000BB">strtotime</span><span style="color: #007700">(</span><span style="color: #DD0000">"last Monday"</span><span style="color: #007700">), </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

   </div>
  </p>
  <p class="para">
   <div class="example" id="example-2">
    <p><strong>Example #2 Controllo per il fallimento</strong></p>
    <div class="example-contents">
<div class="annotation-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$str </span><span style="color: #007700">= </span><span style="color: #DD0000">'Not Good'</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">// prima di PHP 5.1.0 si sarebbe dovuto fare il confronto con -1, invece di false<br /></span><span style="color: #007700">if ((</span><span style="color: #0000BB">$timestamp </span><span style="color: #007700">= </span><span style="color: #0000BB">strtotime</span><span style="color: #007700">(</span><span style="color: #0000BB">$str</span><span style="color: #007700">)) === </span><span style="color: #0000BB">false</span><span style="color: #007700">) {<br />    echo </span><span style="color: #DD0000">"The string (</span><span style="color: #0000BB">$str</span><span style="color: #DD0000">) is bogus"</span><span style="color: #007700">;<br />} else {<br />    echo </span><span style="color: #DD0000">"</span><span style="color: #0000BB">$str</span><span style="color: #DD0000"> == " </span><span style="color: #007700">. </span><span style="color: #0000BB">date</span><span style="color: #007700">(</span><span style="color: #DD0000">'l dS \o\f F Y h:i:s A'</span><span style="color: #007700">, </span><span style="color: #0000BB">$timestamp</span><span style="color: #007700">);<br />}<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

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


 <div class="refsect1 notes" id="refsect1-function.strtotime-notes">
  <h3 class="title">Note</h3>
  <blockquote class="note"><p><strong class="note">Nota</strong>: 
   <p class="para">
    Se è specificato il numero dell&#039;anno in un formato a due cifre, i valori
    tra 00-69 sono mappati a 2000-2069 e 70-99 a 1970-1999. Guardare le note
    sotto per le possibili differenze sui sistemi 32bit (le possibili date potrebbero finire sul
    2038-01-19 03:14:07).
   </p>
  </p></blockquote>
  <blockquote class="note"><p><strong class="note">Nota</strong>: 
   <p class="para">
    Il range valido di un timestamp è tipicamente da Fri, 13 Dec
    1901 20:45:54 UTC a Tue, 19 Jan 2038 03:14:07 UTC. (Queste sono
    le date che corrispondono al minimo e al massimo valore per
    un intero con segno a 32-bit.)
   </p>
   <p class="para">
    Prima di PHP 5.1.0, non tutte le piattaforme supportano timestamp negativi, perciò
    il range delle date può essere limitato a non prima della Unix epoch. Questo
    significa che per esempio le date prima di Jan 1, 1970 non funzioneranno su Windows,
    alcune distribuzioni Linux, e pochi altri sistemi operativi.
   </p>
   <p class="para">
    Per le versioni di PHP a 64-bit, il range valido di un timestamp è effettivamente
    infinito, dato che 64 bit possono rappresentare approssimativamente 293 miliardi di anni in entrambi
    le direzioni.
   </p>
  </p></blockquote>
  <blockquote class="note"><p><strong class="note">Nota</strong>: 
   <p class="para">
    Le date nei formati <code class="literal">m/d/y</code> o <code class="literal">d-m-y</code>
    sono differenziati in base al separatore tra i vari
    componenti: se il separatore è uno slash (<code class="literal">/</code>), allora
    è assunto l&#039;americano <code class="literal">m/d/y</code>; mentre se il separatore è un
    trattino (<code class="literal">-</code>) o un puntino (<code class="literal">.</code>), allora è
    assunto il formato europeo <code class="literal">d-m-y</code>.
    Se, comunque, l&#039;anno viene dato in un formato a due cifre e il separatore è un
    trattino (<code class="literal">-</code>, la stringa data è analizzata come
    <code class="literal">y-m-d</code>.
   </p>
   <p class="para">
    Per evitare potenziali ambiguità, è meglio usare le date
    ISO 8601 (<code class="literal">YYYY-MM-DD</code>) o
    <span class="methodname"><a href="datetime.createfromformat.php" class="methodname">DateTime::createFromFormat()</a></span> quando possibile.
   </p>
  </p></blockquote>
  <blockquote class="note"><p><strong class="note">Nota</strong>: 
   <p class="para">
    Usando questa funzione per operazioni matematiche non è consigliabile.
    È meglio usare <span class="methodname"><a href="datetime.add.php" class="methodname">DateTime::add()</a></span> e
    <span class="methodname"><a href="datetime.sub.php" class="methodname">DateTime::sub()</a></span> in PHP 5.3 e successivi, o
    <span class="methodname"><a href="datetime.modify.php" class="methodname">DateTime::modify()</a></span> in PHP 5.2.
   </p>
  </p></blockquote>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.strtotime-seealso">
  <h3 class="title">Vedere anche:</h3>
  <p class="para">
   <ul class="simplelist">
    <li><a href="datetime.formats.php" class="link">Formati di Data e Tempo</a></li>
    <li><span class="methodname"><a href="datetime.createfromformat.php" class="methodname" rel="rdfs-seeAlso">DateTime::createFromFormat()</a> - Parses a time string according to a specified format</span></li>
    <li><span class="function"><a href="function.checkdate.php" class="function" rel="rdfs-seeAlso">checkdate()</a> - Valida una data gregoriana</span></li>
    <li><span class="function"><a href="function.strptime.php" class="function" rel="rdfs-seeAlso">strptime()</a> - Parse a time/date generated with strftime</span></li>
   </ul>
  </p>
 </div>

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