-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathdate.xml
More file actions
256 lines (237 loc) · 8.2 KB
/
date.xml
File metadata and controls
256 lines (237 loc) · 8.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
<?xml version="1.0" encoding="UTF-8"?>
<!-- EN-Revision: 0466dd93f73635c728c6c4707aaf5876692f1ef3 Maintainer: pastore Status: ready -->
<!-- CREDITS: curcio_it -->
<refentry xml:id="function.date" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>date</refname>
<refpurpose>Formatta un timestamp Unix</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>string</type><methodname>date</methodname>
<methodparam><type>string</type><parameter>format</parameter></methodparam>
<methodparam choice="opt"><type class="union"><type>int</type><type>null</type></type><parameter>timestamp</parameter><initializer>&null;</initializer></methodparam>
</methodsynopsis>
<para>
Restituisce una stringa formattata in accordo con il formato della stringa data usando
l'intero <parameter>timestamp</parameter> dato (timestamp Unix) o l'orario corrente
se nessun timestamp è dato. In altre parole, <parameter>timestamp</parameter>
è opzionale e di default prende il valore di <function>time</function>.
</para>
<warning>
<para>
I timestamp Unix non gestiscono i fusi orari. Utilizzare la
classe <classname>DateTimeImmutable</classname>, e i suoi
metodi di formattazione <methodname>DateTimeInterface::format</methodname> per
formattare le informazioni data/ora con un fuso orario allegato.
</para>
</warning>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<variablelist>
<varlistentry>
<term><parameter>format</parameter></term>
<listitem>
<para>
Formato accettato da <methodname>DateTimeInterface::format</methodname>.
</para>
</listitem>
</varlistentry>
&date.timestamp.description;
</variablelist>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Restituisce una stringa data formattata. Se viene utilizzato un valore non numerico per
<parameter>timestamp</parameter>, viene restituito &false; e viene
emesso un errore di livello <constant>E_WARNING</constant>.
</para>
</refsect1>
<refsect1 role="errors">
&reftitle.errors;
&date.timezone.errors.description;
</refsect1>
<refsect1 role="changelog">
&reftitle.changelog;
<para>
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>&Version;</entry>
<entry>&Description;</entry>
</row>
</thead>
<tbody>
<row>
<entry>8.0.0</entry>
<entry>
<parameter>timestamp</parameter> ora è nullable.
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Esempi di <function>date</function></title>
<programlisting role="php">
<![CDATA[
<?php
// imposta il fuso orario di default da utilizzare.
date_default_timezone_set('UTC');
// Stampa qualcosa di simile a: Monday
echo date("l");
// Stampa qualcosa di simile a: Monday 8th of August 2005 03:12:46 PM
echo date('l jS \of F Y h:i:s A');
// Stampa: July 1, 2000 is on a Saturday
echo "July 1, 2000 is on a " . date("l", mktime(0, 0, 0, 7, 1, 2000));
/* usa le costanti nel parametro format */
// stampa qualcosa di simile a: Wed, 25 Sep 2013 15:28:57 -0700
echo date(DATE_RFC2822);
// stampa qualcosa di simile a: 2000-07-01T00:00:00+00:00
echo date(DATE_ATOM, mktime(0, 0, 0, 7, 1, 2000));
?>
]]>
</programlisting>
</example>
</para>
<para>
È possibile evitare che un carattere riconosciuto nella stringa formato venga
espanso effettuando l'escape di esso anteponendo un backslash. Se il carattere con
un backslash è già una sequenza speciale, potrebbe essere necessario effettuare l'escape anche
del backslash.
<example>
<title>Effettuare l'escape dei caratteri in <function>date</function></title>
<programlisting role="php">
<![CDATA[
<?php
// stampa qualcosa di simile a: Wednesday the 15th
echo date('l \t\h\e jS');
?>
]]>
</programlisting>
</example>
</para>
<para>
È possibile utilizzare insieme <function>date</function> e
<function>mktime</function> per trovare date nel futuro
o nel passato.
<example>
<title>Esempio di <function>date</function> e di <function>mktime</function></title>
<programlisting role="php">
<![CDATA[
<?php
$tomorrow = mktime(0, 0, 0, date("m") , date("d")+1, date("Y"));
$lastmonth = mktime(0, 0, 0, date("m")-1, date("d"), date("Y"));
$nextyear = mktime(0, 0, 0, date("m"), date("d"), date("Y")+1);
?>
]]>
</programlisting>
</example>
<note>
<para>
Questo può essere più affidabile rispetto che semplicemente aggiungere o sottrarre il numero
di secondi in un giorno o in un mese ad un timestamp a causa dell'ora
legale.
</para>
</note>
</para>
<para>
Alcuni esempi della formattazione <function>date</function>. Notare che
si dovrebbe effettuare l'escape di qualsiasi altro carattere, come tutti quelli che
attualmente hanno un significato speciale produrranno risultati indesiderati, e
ad altri caratteri potrebbe essere assegnato un significato nelle versioni future di PHP.
Quando si effettua l'escape, assicurarsi di usare gli apici singoli in modo da evitare che i caratteri
come \n divengano nuove linee.
<example>
<title>Formattazione di <function>date</function></title>
<programlisting role="php">
<![CDATA[
<?php
// Assumendo che oggi sia Il 10 Marzo, 2001, 5:16:18 pm, e che noi siamo nel
// Fuso Orario Mountain Standard Time (MST)
$today = date("F j, Y, g:i a"); // March 10, 2001, 5:16 pm
$today = date("m.d.y"); // 03.10.01
$today = date("j, n, Y"); // 10, 3, 2001
$today = date("Ymd"); // 20010310
$today = date('h-i-s, j-m-y, it is w Day'); // 05-16-18, 10-03-01, 1631 1618 6 Satpm01
$today = date('\i\t \i\s \t\h\e jS \d\a\y.'); // it is the 10th day.
$today = date("D M j G:i:s T Y"); // Sat Mar 10 17:16:18 MST 2001
$today = date('H:m:s \m \i\s\ \m\o\n\t\h'); // 17:03:18 m is month
$today = date("H:i:s"); // 17:16:18
$today = date("Y-m-d H:i:s"); // 2001-03-10 17:16:18 (the MySQL DATETIME format)
?>
]]>
</programlisting>
</example>
</para>
<para>
Per formattare le date in altri lingue,
può essere utilizzata <methodname>IntlDateFormatter::format</methodname>
al posto di <function>date</function>.
</para>
</refsect1>
<refsect1 role="notes">
&reftitle.notes;
<note>
<para>
Per generare un timestamp da una stringa che rappresenta la data, si
può essere in grado di utilizzare <function>strtotime</function>. Inoltre, alcuni
database hanno delle funzioni per convertire i loro formati data in timestamp
(come la funzione <link xlink:href="&url.mysql.docs.date;">UNIX_TIMESTAMP</link>
di MySQL).
</para>
</note>
<tip>
<para>
Il timestamp dell'inizio della richiesta è disponibile in
<varname>$_SERVER['REQUEST_TIME']</varname>.
</para>
</tip>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><methodname>DateTimeImmutable::__construct</methodname></member>
<member><methodname>DateTimeInterface::format</methodname></member>
<member><function>gmdate</function></member>
<member><function>idate</function></member>
<member><function>getdate</function></member>
<member><function>getlastmod</function></member>
<member><function>mktime</function></member>
<member><methodname>IntlDateFormatter::format</methodname></member>
<member><function>time</function></member>
<member><link linkend="datetimeinterface.constants.types">Costanti di DateTime Predefinite</link></member>
</simplelist>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->