reference/datetime/functions/time.xml
5c951013ca04161992efed8b86fb40f55669958e
...
...
@@ -16,6 +16,27 @@
16
16
Returns the current time measured in the number of seconds since
17
17
the Unix Epoch (January 1 1970 00:00:00 GMT).
18
18
</para>
19
+
<note>
20
+
<para>
21
+
Unix timestamps do not contain any information with regards to any local
22
+
timezone. It is recommended to use the
23
+
<classname>DateTimeImmutable</classname> class for handling date and time
24
+
information in order to avoid the pitfalls that come with just Unix
25
+
timestamps.
26
+
</para>
27
+
</note>
28
+
</refsect1>
29
+

30
+
<refsect1 role="parameters">
31
+
&reftitle.parameters;
32
+
&no.function.parameters;
33
+
</refsect1>
34
+

35
+
<refsect1 role="returnvalues">
36
+
&reftitle.returnvalues;
37
+
<para>
38
+
Returns the current timestamp.
39
+
</para>
19
40
</refsect1>
20
41

21
42
<refsect1 role="examples">
...
...
@@ -26,21 +47,14 @@
26
47
<programlisting role="php">
27
48
<![CDATA[
28
49
<?php
29
-
$nextWeek = time() + (7 * 24 * 60 * 60);
30
-
// 7 days; 24 hours; 60 mins; 60 secs
31
-
echo 'Now: '. date('Y-m-d') ."\n";
32
-
echo 'Next Week: '. date('Y-m-d', $nextWeek) ."\n";
33
-
// or using strtotime():
34
-
echo 'Next Week: '. date('Y-m-d', strtotime('+1 week')) ."\n";
50
+
echo 'Now: '. time();
35
51
?>
36
52
]]>
37
53
</programlisting>
38
54
&example.outputs.similar;
39
55
<screen>
40
56
<![CDATA[
41
-
Now: 2005-03-30
42
-
Next Week: 2005-04-06
43
-
Next Week: 2005-04-06
57
+
Now: 1660338149
44
58
]]>
45
59
</screen>
46
60
</example>
...
...
@@ -52,7 +66,7 @@ Next Week: 2005-04-06
52
66
<tip>
53
67
<para>
54
68
Timestamp of the start of the request is available in
55
-
<varname>$_SERVER['REQUEST_TIME']</varname> since PHP 5.1.
69
+
<varname>$_SERVER['REQUEST_TIME']</varname>.
56
70
</para>
57
71
</tip>
58
72
</refsect1>
...
...
@@ -61,6 +75,7 @@ Next Week: 2005-04-06
61
75
&reftitle.seealso;
62
76
<para>
63
77
<simplelist>
78
+
<member><classname>DateTimeImmutable</classname></member>
64
79
<member><function>date</function></member>
65
80
<member><function>microtime</function></member>
66
81
</simplelist>
67
82