1
0
mirror of https://github.com/php/doc-ru.git synced 2026-03-28 01:32:09 +01:00
Files
archived-doc-ru/reference/datetime/datetimeimmutable/modify.xml
2023-12-12 22:29:45 +03:00

153 lines
4.4 KiB
XML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?xml version="1.0" encoding="utf-8"?>
<!-- EN-Revision: a11c5b53bc132289a0ddcc6d3efee5d97f0027b4 Maintainer: shein Status: ready -->
<!-- Reviewed: no -->
<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>Создаёт новый объект с изменённой временной меткой</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>
Создаёт новый объект <type>DateTimeImmutable</type> с изменённой временной меткой.
Первоначальный объект не изменяется.
</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>
Возвращает новый модифицированный объект DateTimeImmutable&return.falseforfailure;.
</para>
</refsect1>
<refsect1 role="errors">
&reftitle.errors;
<para>
Если передана строка с недопустимой датой/временем,
выбрасывается исключение <exceptionname>DateMalformedStringException</exceptionname>.
До PHP 8.3 появлялось предупреждение.
</para>
</refsect1>
<refsect1 role="changelog">
&reftitle.changelog;
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>&Version;</entry>
<entry>&Description;</entry>
</row>
</thead>
<tbody>
<row>
<entry>8.3.0</entry>
<entry>
Теперь вместо предупреждения выбрасывается исключение
<exceptionname>DateMalformedStringException</exceptionname>,
если передана недопустимая строка.
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<example>
<title>Пример использования <function>DateTimeImmutable::modify</function></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>Будьте осторожны при сложении или вычитании месяцев</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
-->