cvs: phpdoc /en/reference/datetime/functions idate.xml

From: Date: Mon, 28 Jun 2004 15:04:03 +0000
Subject: cvs: phpdoc /en/reference/datetime/functions idate.xml
Groups: php.doc 
Request: Send a blank email to phpdoc+get-969361554@lists.php.net to get a copy of this message
nlopess Mon Jun 28 11:04:03 2004 EDT Modified files: /phpdoc/en/reference/datetime/functions idate.xml Log: add an explanation and an example about problems in two digits years http://cvs.php.net/diff.php/phpdoc/en/reference/datetime/functions/idate.xml?r1=1.2&r2=1.3&ty=u Index: phpdoc/en/reference/datetime/functions/idate.xml diff -u phpdoc/en/reference/datetime/functions/idate.xml:1.2 phpdoc/en/reference/datetime/functions/idate.xml:1.3 --- phpdoc/en/reference/datetime/functions/idate.xml:1.2 Sat May 29 10:02:46 2004 +++ phpdoc/en/reference/datetime/functions/idate.xml Mon Jun 28 11:04:02 2004 @@ -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> @@ -107,6 +111,29 @@ </tbody> </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

« previous php.doc (#969361554) next »