Skip to content

Commit

Permalink
Integrate user note into the manual
Browse files Browse the repository at this point in the history
  • Loading branch information
sy-records committed Sep 28, 2023
1 parent 2fd131d commit 1af7512
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion reference/datetime/datetimeinterface/diff.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: 02ff7fef5b34cf8f5395180d9d39fb64d9398d00 Maintainer: mowangjuanzi Status: ready -->
<!-- EN-Revision: dbbcd32d72e4c9af14e9f3b940edbedfb54f965e Maintainer: mowangjuanzi Status: ready -->
<!-- CREDITS: Luffy -->
<refentry xml:id="datetime.diff" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>DateTimeInterface::diff</refname>
Expand Down Expand Up @@ -134,6 +135,31 @@ echo $interval->format("%H:%I:%S (Full days: %a)"), "\n";
</screen>
</example>

<example>
<title><methodname>DateTimeInterface::diff</methodname> range</title>
<para>
该方法返回的值是从 <parameter>$this</parameter> 到达 <parameter>$targetObject</parameter>
所需要的精确时间。因此,将 1 月 1 日与 12 月 31 日进行比较,返回的结果是 364,而不是
365 天(对于非闰年)。
</para>
<programlisting role="php">
<![CDATA[
<?php
$originalTime = new DateTimeImmutable("2023-01-01 UTC");
$targedTime = new DateTimeImmutable("2023-12-31 UTC");
$interval = $originalTime->diff($targedTime);
echo "Full days: ", $interval->format("%a"), "\n";
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
Full days: 364
]]>
</screen>
</example>

<example>
<title><classname>DateTime</classname> 对象比较</title>
<note>
Expand Down

0 comments on commit 1af7512

Please sign in to comment.