mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
add an explanation and an example about problems in two digits years
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@162237 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
c87571bd71
commit
1a891a9b98
1 changed files with 31 additions and 4 deletions
|
@ -1,5 +1,5 @@
|
|||
<?xml version='1.0' encoding='iso-8859-1'?>
|
||||
<!-- $Revision: 1.2 $ -->
|
||||
<!-- $Revision: 1.3 $ -->
|
||||
<refentry id="function.idate">
|
||||
<refnamediv>
|
||||
<refname>idate</refname>
|
||||
|
@ -17,14 +17,18 @@
|
|||
<para>
|
||||
Returns a string formatted according to the given format string using the
|
||||
given integer <parameter>timestamp</parameter> or the current local time
|
||||
if no timestamp is given. In otherwords, <parameter>timestamp</parameter>
|
||||
if no timestamp is given. In other words, <parameter>timestamp</parameter>
|
||||
is optional and defaults to the value of <function>time</function>.
|
||||
</para>
|
||||
<para>
|
||||
Unlike the function <function>date</function>, <function>idate</function>
|
||||
accepts just one char in the <parameter>format</parameter> parameter.
|
||||
</para>
|
||||
<para>
|
||||
<table>
|
||||
<title>The following characters are recognized in the
|
||||
<parameter>format</parameter> parameter string</title>
|
||||
<tgroup cols="3">
|
||||
<tgroup cols="2">
|
||||
<thead>
|
||||
<row>
|
||||
<entry><parameter>format</parameter> character</entry>
|
||||
|
@ -90,7 +94,7 @@
|
|||
</row>
|
||||
<row>
|
||||
<entry><literal>y</literal></entry>
|
||||
<entry>Year (2 digits)</entry>
|
||||
<entry>Year (1 or 2 digits - check note below)</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><literal>Y</literal></entry>
|
||||
|
@ -108,6 +112,29 @@
|
|||
</tgroup>
|
||||
</table>
|
||||
</para>
|
||||
<note>
|
||||
<para>
|
||||
As <function>idate</function> returns always an <type>integer</type> and
|
||||
as they can't start with a "0", <function>idate</function> may return less
|
||||
digits then you would expect. See the example below:
|
||||
</para>
|
||||
</note>
|
||||
<para>
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$timestamp = strtotime('1st January 2004'); //1072915200
|
||||
|
||||
// this prints the year in a two digit format
|
||||
// however, as this would start with a "0", it
|
||||
// only prints "4"
|
||||
echo idate('y', $timestamp);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
<para>
|
||||
See also <function>date</function> and
|
||||
<function>time</function>.
|
||||
|
|
Loading…
Reference in a new issue