svn: /phpdoc/en/trunk/reference/datetime/dateinterval/ format.xml

From: Date: Tue, 04 May 2010 10:06:59 +0000
Subject: svn: /phpdoc/en/trunk/reference/datetime/dateinterval/ format.xml
Groups: php.doc.cvs 
Request: Send a blank email to doc-cvs+get-6571@lists.php.net to get a copy of this message
aharvey Tue, 04 May 2010 10:06:59 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=298955 Log: Added an example to make clearer the misunderstanding that led to bug #51737 (Having a bug when using date_diff($t1,$t2)). Bug: http://bugs.php.net/51737 (Closed) Having a bug when using date_diff($t1,$t2) Changed paths: U phpdoc/en/trunk/reference/datetime/dateinterval/format.xml Modified: phpdoc/en/trunk/reference/datetime/dateinterval/format.xml =================================================================== --- phpdoc/en/trunk/reference/datetime/dateinterval/format.xml 2010-05-04 10:06:09 UTC (rev 298954) +++ phpdoc/en/trunk/reference/datetime/dateinterval/format.xml 2010-05-04 10:06:59 UTC (rev 298955) @@ -196,6 +196,39 @@ </screen> </example> </para> + <para> + <example> + <title> + <classname>DateInterval</classname> and + <methodname>DateTime::diff</methodname> with the %a and %d modifiers + </title> + <programlisting role="php"> +<![CDATA[ +<?php + +$january = new DateTime('2010-01-01'); +$february = new DateTime('2010-02-01'); +$interval = $february->diff($january); + +// %a will output the total number of days. +echo $interval->format('%a total days')."\n"; + +// While %d will only output the number of days not alrady covered by the +// month. +echo $interval->format('%m month, %d days'); + +?> +]]> + </programlisting> + &example.outputs; + <screen role="php"> +<![CDATA[ +31 total days +1 month, 0 days +]]> + </screen> + </example> + </para> </refsect1> </refentry>

« previous php.doc.cvs (#6571) next »