1
0
mirror of https://github.com/php/doc-en.git synced 2026-03-24 07:42:10 +01:00
Files
archived-doc-en/reference/datetime/datetimeimmutable/modify.xml
2022-12-11 16:34:22 +01:00

119 lines
3.1 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="datetimeimmutable.modify" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>DateTimeImmutable::modify</refname>
<refpurpose>Creates a new object with modified timestamp</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis role="DateTimeImmutable">
<modifier>public</modifier> <type class="union"><type>DateTimeImmutable</type><type>false</type></type><methodname>DateTimeImmutable::modify</methodname>
<methodparam><type>string</type><parameter>modifier</parameter></methodparam>
</methodsynopsis>
<para>
Creates a new <type>DateTimeImmutable</type> object with modified timestamp.
The original object is not modified.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<variablelist>
<varlistentry>
<term><parameter>modifier</parameter></term>
<listitem>
<para>&date.formats.parameter;</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Returns a new modified DateTimeImmutable object&return.falseforfailure;.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<example>
<title><function>DateTimeImmutable::modify</function> example</title>
<para>&style.oop;</para>
<programlisting role="php">
<![CDATA[
<?php
$date = new DateTimeImmutable('2006-12-12');
$newDate = $date->modify('+1 day');
echo $newDate->format('Y-m-d');
?>
]]>
</programlisting>
&examples.outputs;
<screen>
<![CDATA[
2006-12-13
]]>
</screen>
</example>
<example>
<title>Beware when adding or subtracting months</title>
<programlisting role="php">
<![CDATA[
<?php
$date = new DateTimeImmutable('2000-12-31');
$newDate1 = $date->modify('+1 month');
echo $newDate1->format('Y-m-d') . "\n";
$newDate2 = $newDate1->modify('+1 month');
echo $newDate2->format('Y-m-d') . "\n";
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
2001-01-31
2001-03-03
]]>
</screen>
</example>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<simplelist>
<member><function>DateTimeImmutable::add</function></member>
<member><function>DateTimeImmutable::sub</function></member>
<member><function>DateTimeImmutable::setDate</function></member>
<member><function>DateTimeImmutable::setISODate</function></member>
<member><function>DateTimeImmutable::setTime</function></member>
<member><function>DateTimeImmutable::setTimestamp</function></member>
</simplelist>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->