Fix 33223 and move to new doc style

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@187558 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Matt Li 2005-06-03 08:46:16 +00:00
parent 7a1882f63d
commit 67963fd976

View file

@ -1,13 +1,14 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.16 $ -->
<!-- $Revision: 1.17 $ -->
<!-- splitted from ./en/functions/datetime.xml, last change in rev 1.2 -->
<refentry id="function.mktime">
<refnamediv>
<refname>mktime</refname>
<refpurpose>Get Unix timestamp for a date</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>int</type><methodname>mktime</methodname>
<methodparam choice="opt"><type>int</type><parameter>hour</parameter></methodparam>
@ -18,13 +19,6 @@
<methodparam choice="opt"><type>int</type><parameter>year</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>is_dst</parameter></methodparam>
</methodsynopsis>
<para>
<emphasis>Warning:</emphasis> Note the strange order of
arguments, which differs from the order of arguments in a regular
Unix mktime() call and which does not lend itself well to leaving
out parameters from right to left (see below). It is a common
error to mix these values up in a script.
</para>
<para>
Returns the Unix timestamp corresponding to the arguments
given. This timestamp is a long integer containing the number of
@ -36,33 +30,129 @@
arguments thus omitted will be set to the current value according
to the local date and time.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<parameter>is_dst</parameter> can be set to 1 if the time is
during daylight savings time (DST), 0 if it is not, or -1 (the default)
if it is unknown whether the time is within daylight savings time
or not. If it's unknown, PHP tries to figure it out itself. This can
cause unexpected (but not incorrect) results.
<variablelist>
<varlistentry>
<term><parameter>hour</parameter></term>
<listitem>
<para>
The number of the hour.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>minute</parameter></term>
<listitem>
<para>
The number of the minute.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>second</parameter></term>
<listitem>
<para>
The number of seconds past the minute.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>month</parameter></term>
<listitem>
<para>
The number of the month.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>day</parameter></term>
<listitem>
<para>
The number of the day.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>year</parameter></term>
<listitem>
<para>
The number of the year, may be a two or four digit value,
with values between 0-69 mapping to 2000-2069 and 70-99 to
1970-1999 (on systems where time_t is a 32bit signed integer, as
most common today, the valid range for <parameter>year</parameter>
is somewhere between 1901 and 2038).
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>is_dst</parameter></term>
<listitem>
<para>
This parameter can be set to 1 if the time is during daylight savings time (DST),
0 if it is not, or -1 (the default) if it is unknown whether the time is within
daylight savings time or not. If it's unknown, PHP tries to figure it out itself.
This can cause unexpected (but not incorrect) results.
Some times are invalid if DST is enabled on the system PHP is running on or
<parameter>is_dst</parameter> is set to 1. If DST is enabled in e.g. 2:00, all times
between 2:00 and 3:00 are invalid and <function>mktime</function> returns an undefined
(usually negative) value.
Some systems (e.g. Solaris 8) enable DST at midnight so time 0:30 of the day when DST
is enabled is evaluated as 23:30 of the previous day.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Some times are invalid if DST is enabled on the system PHP is running on
or <parameter>is_dst</parameter> is set to 1. If DST is enabled in e.g.
2:00, all times between 2:00 and 3:00 are invalid and
<function>mktime</function> returns an undefined (usually negative) value.
Some systems (e.g. Solaris 8) enable DST at midnight so time 0:30
of the day when DST is enabled is evaluated as 23:30 of the previous day.
<function>mktime</function> returns the Unix timestamp of the arguments
given.
If the arguments are invalid (eg. if the year, month and day are all 0), the
function returns <literal>-1</literal>.
</para>
<note>
<para>
<parameter>is_dst</parameter> was added in 3.0.10.
</para>
</note>
</refsect1>
<refsect1 role="changelog">
&reftitle.changelog;
<para>
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>&Version;</entry>
<entry>&Description;</entry>
</row>
</thead>
<tbody>
<row>
<entry>3.0.10</entry>
<entry>Added <parameter>is_dst</parameter> parameter</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<function>mktime</function> is useful for doing date arithmetic
and validation, as it will automatically calculate the correct
value for out-of-range input. For example, each of the following
lines produces the string "Jan-01-1998".
<example>
<title><function>mktime</function> example</title>
<para>
<function>mktime</function> is useful for doing date arithmetic
and validation, as it will automatically calculate the correct
value for out-of-range input. For example, each of the following
lines produces the string "Jan-01-1998".
</para>
<programlisting role="php">
<![CDATA[
<?php
@ -74,34 +164,20 @@ echo date("M-d-Y", mktime(0, 0, 0, 1, 1, 98));
]]>
</programlisting>
</example>
<parameter>Year</parameter> may be a two or four digit value,
with values between 0-69 mapping to 2000-2069 and 70-99 to
1970-1999 (on systems where time_t is a 32bit signed integer, as
most common today, the valid range for
<parameter>year</parameter> is somewhere between 1901 and 2038).
</para>
<para>
<note>
<title>Windows</title>
<simpara>
Negative timestamps are not supported under any known version
of Windows. Therefore the range of valid years includes only 1970
through 2038.
</simpara>
</note>
</para>
<para>
The last day of any given month can be expressed as the "0" day
of the next month, not the -1 day. Both of the following examples
will produce the string "The last day in Feb 2000 is: 29".
<example>
<title>Last day of next month</title>
<para>
The last day of any given month can be expressed as the "0" day
of the next month, not the -1 day. Both of the following examples
will produce the string "The last day in Feb 2000 is: 29".
</para>
<programlisting role="php">
<![CDATA[
<?php
$lastday = mktime(0, 0, 0, 3, 0, 2000);
echo strftime("Last day in Feb 2000 is: %d", $lastday);
$lastday = mktime(0, 0, 0, 4, -31, 2000);
echo strftime("Last day in Feb 2000 is: %d", $lastday);
?>
@ -109,14 +185,27 @@ echo strftime("Last day in Feb 2000 is: %d", $lastday);
</programlisting>
</example>
</para>
<simpara>
Date with year, month and day equal to zero is considered illegal
(otherwise it what be regarded as 30.11.1999, which would be strange
behavior).
</simpara>
</refsect1>
<refsect1 role="notes">
&reftitle.notes;
<caution>
<para>
Negative timestamps are not supported under any known version
of Windows. Therefore the range of valid years includes only 1970
through 2038.
</para>
</caution>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
See also <function>gmmktime</function>,
<function>date</function> and <function>time</function>.
<simplelist>
<member><function>gmmktime</function></member>
<member><function>date</function></member>
<member><function>time</function></member>
</simplelist>
</para>
</refsect1>
</refentry>