Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion reference/datetime/book.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->

<book xml:id="book.datetime" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<book xml:id="book.datetime" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" annotations="interactive">
<?phpdoc extension-membership="core"?>
<title>Date and Time</title>
<titleabbrev>Date/Time</titleabbrev>
Expand Down
5 changes: 2 additions & 3 deletions reference/datetime/dateinterval/construct.xml
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,9 @@ echo $interval->format("%d");
</programlisting>
&example.outputs;
<screen role="php">
<![CDATA[
7
]]>
</screen>
</example>
</para>
Expand All @@ -199,11 +201,8 @@ echo $interval->format("%d");
<programlisting role="php">
<![CDATA[
<?php

$interval = new DateInterval('P1W2D');
var_dump($interval);

?>
]]>
</programlisting>
&example.outputs.82;
Expand Down
8 changes: 4 additions & 4 deletions reference/datetime/dateinterval/createfromdatestring.xml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
<para>
<example>
<title>Parsing valid date intervals</title>
<programlisting role="php">
<programlisting role="php" annotations="non-interactive">
<![CDATA[
<?php
// Each set of intervals is equal.
Expand All @@ -130,7 +130,6 @@ $i = DateInterval::createFromDateString('1 day + 12 hours');

$i = new DateInterval('PT3600S');
$i = DateInterval::createFromDateString('3600 seconds');
?>
]]>
</programlisting>
</example>
Expand All @@ -146,13 +145,14 @@ echo $i->format('%d %h %i'), "\n";

$i = DateInterval::createFromDateString('1 year - 10 days');
echo $i->format('%y %d'), "\n";
?>
]]>
</programlisting>
&example.outputs;
<screen role="shell">
<screen>
<![CDATA[
449 2 70
1 -10
]]>
</screen>
</example>
</para>
Expand Down
9 changes: 0 additions & 9 deletions reference/datetime/dateinterval/format.xml
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,8 @@
<programlisting role="php">
<![CDATA[
<?php

$interval = new DateInterval('P2Y4DT6H8M');
echo $interval->format('%d days');

?>
]]>
</programlisting>
&example.outputs;
Expand All @@ -206,11 +203,8 @@ echo $interval->format('%d days');
<programlisting role="php">
<![CDATA[
<?php

$interval = new DateInterval('P32D');
echo $interval->format('%d days');

?>
]]>
</programlisting>
&example.outputs;
Expand All @@ -230,7 +224,6 @@ echo $interval->format('%d days');
<programlisting role="php">
<![CDATA[
<?php

$january = new DateTime('2010-01-01');
$february = new DateTime('2010-02-01');
$interval = $february->diff($january);
Expand All @@ -241,8 +234,6 @@ echo $interval->format('%a total days')."\n";
// While %d will only output the number of days not already covered by the
// month.
echo $interval->format('%m month, %d days');

?>
]]>
</programlisting>
&example.outputs;
Expand Down
7 changes: 5 additions & 2 deletions reference/datetime/dateperiod.xml
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@
<para>
<informalexample>
<programlisting role="php">
<![CDATA[<?php
<![CDATA[
<?php
$start = new DateTime('2018-12-31 00:00:00');
$end = new DateTime('2021-12-31 00:00:00');
$interval = new DateInterval('P1M');
Expand All @@ -184,15 +185,17 @@ echo $period->recurrences, "\n";

$period = new DatePeriod($start, $interval, $end, DatePeriod::EXCLUDE_START_DATE);
echo $period->recurrences, "\n";
?>]]>
]]>
</programlisting>
&example.outputs;
<screen role="php">
<![CDATA[
5
6
7
1
0
]]>
</screen>
</informalexample>
</para>
Expand Down
4 changes: 1 addition & 3 deletions reference/datetime/dateperiod/construct.xml
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,6 @@ $period = new DatePeriod($iso);
foreach ($period as $date) {
echo $date->format('Y-m-d')."\n";
}
?>
]]>
</programlisting>
&example.outputs;
Expand All @@ -231,6 +230,7 @@ foreach ($period as $date) {
<programlisting role="php">
<![CDATA[
<?php
Deprecated: Calling DatePeriod::__construct(string $isostr, int $options = 0) is deprecated, use DatePeriod::createFromISO8601String() instead in script on line 11
$start = new DateTime('2012-07-01');
$interval = new DateInterval('P7D');
$end = new DateTime('2012-07-31');
Expand All @@ -244,7 +244,6 @@ $period = new DatePeriod($start, $interval, $end,
foreach ($period as $date) {
echo $date->format('Y-m-d')."\n";
}
?>
]]>
</programlisting>
&example.outputs;
Expand Down Expand Up @@ -273,7 +272,6 @@ $period = new DatePeriod($begin, $interval, $end, DatePeriod::EXCLUDE_START_DATE
foreach ($period as $dt) {
echo $dt->format('l Y-m-d'), "\n";
}
?>
]]>
</programlisting>
&example.outputs;
Expand Down
2 changes: 0 additions & 2 deletions reference/datetime/dateperiod/createfromiso8601string.xml
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,13 @@
<![CDATA[
<?php
$iso = 'R4/2023-07-01T00:00:00Z/P7D';

$period = DatePeriod::createFromISO8601String($iso);

// By iterating over the DatePeriod object, all of the
// recurring dates within that period are printed.
foreach ($period as $date) {
echo $date->format('Y-m-d'), "\n";
}
?>
]]>
</programlisting>
&example.outputs;
Expand Down
3 changes: 1 addition & 2 deletions reference/datetime/dateperiod/getdateinterval.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,9 @@
<programlisting role="php">
<![CDATA[
<?php
$period = new DatePeriod('R7/2016-05-16T00:00:00Z/P1D');
$period = DatePeriod::createFromIso8601String('R7/2016-05-16T00:00:00Z/P1D');
$interval = $period->getDateInterval();
echo $interval->format('%d day');
?>
]]>
</programlisting>
&example.outputs;
Expand Down
2 changes: 0 additions & 2 deletions reference/datetime/dateperiod/getenddate.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ $period = new DatePeriod(
);
$start = $period->getEndDate();
echo $start->format(DateTime::ISO8601);
?>
]]>
</programlisting>
&examples.outputs;
Expand All @@ -81,7 +80,6 @@ $period = new DatePeriod(
7
);
var_dump($period->getEndDate());
?>
]]>
</programlisting>
&example.outputs;
Expand Down
9 changes: 6 additions & 3 deletions reference/datetime/dateperiod/getrecurrences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
&reftitle.returnvalues;
<para>
The number of recurrences as set by explicitly passing the
<literal>$recurrences</literal> to the contructor of the
<literal>$recurrences</literal> to the constructor of the
<classname>DatePeriod</classname> class, or &null; otherwise.
</para>
</refsect1>
Expand All @@ -38,7 +38,8 @@
<example>
<title>Different values for <methodname>DatePeriod::getRecurrences</methodname></title>
<programlisting role="php">
<![CDATA[<?php
<![CDATA[
<?php
$start = new DateTime('2018-12-31 00:00:00');
$end = new DateTime('2021-12-31 00:00:00');
$interval = new DateInterval('P1M');
Expand All @@ -60,16 +61,18 @@ var_dump($period->getRecurrences());

$period = new DatePeriod($start, $interval, $end, DatePeriod::EXCLUDE_START_DATE);
var_dump($period->getRecurrences());
?>]]>
]]>
</programlisting>
&example.outputs;
<screen role="php">
<![CDATA[
5
5
5

NULL
NULL
]]>
</screen>
</example>
</para>
Expand Down
3 changes: 1 addition & 2 deletions reference/datetime/dateperiod/getstartdate.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,9 @@
<programlisting role="php">
<![CDATA[
<?php
$period = new DatePeriod('R7/2016-05-16T00:00:00Z/P1D');
$period = DatePeriod::createFromIso8601String('R7/2016-05-16T00:00:00Z/P1D');
$start = $period->getStartDate();
echo $start->format(DateTime::ISO8601);
?>
]]>
</programlisting>
&example.outputs;
Expand Down
4 changes: 1 addition & 3 deletions reference/datetime/datetime/createfromimmutable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,11 @@
<para>
<example>
<title>Creating a mutable date time object</title>
<programlisting role="php">
<programlisting role="php" annotations="non-interactive">
<![CDATA[
<?php
$date = new DateTimeImmutable("2014-06-20 11:45 Europe/London");

$mutable = DateTime::createFromImmutable( $date );
?>
]]>
</programlisting>
</example>
Expand Down
4 changes: 1 addition & 3 deletions reference/datetime/datetime/createfrominterface.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,14 @@
<para>
<example>
<title>Creating a mutable date time object</title>
<programlisting role="php">
<programlisting role="php" annotations="non-interactive">
<![CDATA[
<?php
$date = new DateTimeImmutable("2014-06-20 11:45 Europe/London");

$mutable = DateTime::createFromInterface($date);

$date = new DateTime("2014-06-20 11:45 Europe/London");
$also_mutable = DateTime::createFromInterface($date);
?>
]]>
</programlisting>
</example>
Expand Down
12 changes: 7 additions & 5 deletions reference/datetime/datetime/modify.xml
Original file line number Diff line number Diff line change
Expand Up @@ -92,20 +92,24 @@
$date = new DateTime('2006-12-12');
$date->modify('+1 day');
echo $date->format('Y-m-d');
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
2006-12-13
]]>
</screen>
<para>&style.procedural;</para>
<programlisting role="php">
<![CDATA[
<?php
$date = date_create('2006-12-12');
date_modify($date, '+1 day');
echo date_format($date, 'Y-m-d');
?>
]]>
</programlisting>
&examples.outputs;
&example.outputs;
<screen>
<![CDATA[
2006-12-13
Expand All @@ -124,7 +128,6 @@ echo $date->format('Y-m-d') . "\n";

$date->modify('+1 month');
echo $date->format('Y-m-d') . "\n";
?>
]]>
</programlisting>
&example.outputs;
Expand All @@ -150,7 +153,6 @@ echo $date->format('Y-m-d H:i') . "\n";

$date->modify('17:30');
echo $date->format('Y-m-d H:i') . "\n";
?>
]]>
</programlisting>
&example.outputs;
Expand Down
11 changes: 8 additions & 3 deletions reference/datetime/datetime/settimezone.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,15 @@ echo $date->format('Y-m-d H:i:sP') . "\n";

$date->setTimezone(new DateTimeZone('Pacific/Chatham'));
echo $date->format('Y-m-d H:i:sP') . "\n";
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
2000-01-01 00:00:00+12:00
2000-01-01 01:45:00+13:45
]]>
</screen>
<para>&style.procedural;</para>
<programlisting role="php">
<![CDATA[
Expand All @@ -82,10 +88,9 @@ echo date_format($date, 'Y-m-d H:i:sP') . "\n";

date_timezone_set($date, timezone_open('Pacific/Chatham'));
echo date_format($date, 'Y-m-d H:i:sP') . "\n";
?>
]]>
</programlisting>
&examples.outputs;
&example.outputs;
<screen>
<![CDATA[
2000-01-01 00:00:00+12:00
Expand Down
Loading