mirror of
https://github.com/php/doc-ru.git
synced 2025-08-16 18:22:04 +00:00
179 lines
7.5 KiB
XML
179 lines
7.5 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
||
<!-- EN-Revision: ce46b05403346a4b21937db0b923173431104145 Maintainer: sergey Status: ready -->
|
||
<!-- Reviewed: no -->
|
||
<refentry xml:id="intldateformatter.formatobject" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||
<refnamediv>
|
||
<refname>IntlDateFormatter::formatObject</refname>
|
||
<refname>datefmt_format_object</refname>
|
||
<refpurpose>Форматирует объект</refpurpose>
|
||
</refnamediv>
|
||
|
||
<refsect1 role="description">
|
||
&reftitle.description;
|
||
<para>
|
||
&style.oop;
|
||
</para>
|
||
<methodsynopsis role="oop">
|
||
<modifier>public</modifier> <modifier>static</modifier> <type class="union"><type>string</type><type>false</type></type><methodname>IntlDateFormatter::formatObject</methodname>
|
||
<methodparam><type class="union"><type>IntlCalendar</type><type>DateTime</type></type><parameter>datetime</parameter></methodparam>
|
||
<methodparam choice="opt"><type class="union"><type>array</type><type>int</type><type>string</type><type>null</type></type><parameter>format</parameter><initializer>&null;</initializer></methodparam>
|
||
<methodparam choice="opt"><type class="union"><type>string</type><type>null</type></type><parameter>locale</parameter><initializer>&null;</initializer></methodparam>
|
||
</methodsynopsis>
|
||
<para>
|
||
&style.procedural;
|
||
</para>
|
||
<methodsynopsis role="procedural">
|
||
<type class="union"><type>string</type><type>false</type></type><methodname>datefmt_format_object</methodname>
|
||
<methodparam><type class="union"><type>IntlCalendar</type><type>DateTimeInterface</type></type><parameter>datetime</parameter></methodparam>
|
||
<methodparam choice="opt"><type class="union"><type>array</type><type>int</type><type>string</type><type>null</type></type><parameter>format</parameter><initializer>&null;</initializer></methodparam>
|
||
<methodparam choice="opt"><type class="union"><type>string</type><type>null</type></type><parameter>locale</parameter><initializer>&null;</initializer></methodparam>
|
||
</methodsynopsis>
|
||
|
||
<para>
|
||
Функция позволяет форматировать объект <classname>IntlCalendar</classname> или
|
||
<classname>DateTime</classname> без предварительного явного создания
|
||
объекта <classname>IntlDateFormatter</classname>.
|
||
</para>
|
||
<para>
|
||
Временный <classname>IntlDateFormatter</classname>, который будет создан,
|
||
принимает часовой пояс из переданного объекта. База данных часовых поясов, связанная с PHP,
|
||
не будет использоваться - вместо неё будет использоваться ICU.
|
||
Следовательно, идентификатор часового пояса, используемый в объектах <classname>DateTime</classname>,
|
||
также должен существовать в базе данных ICU.
|
||
</para>
|
||
|
||
</refsect1>
|
||
|
||
<refsect1 role="parameters">
|
||
&reftitle.parameters;
|
||
<variablelist>
|
||
<varlistentry>
|
||
<term><parameter>datetime</parameter></term>
|
||
<listitem>
|
||
<para>
|
||
Объект типа <classname>IntlCalendar</classname> или
|
||
<classname>DateTime</classname>.
|
||
Будет использоваться информация о часовом поясе в объекте.
|
||
</para>
|
||
</listitem>
|
||
</varlistentry>
|
||
<varlistentry>
|
||
<term><parameter>format</parameter></term>
|
||
<listitem>
|
||
<para>
|
||
Как отформатировать дату/время. Может быть либо массив (<type>array</type>) с двумя элементами
|
||
(сначала стиль даты, затем стиль времени, может быть одна из констант: <constant>IntlDateFormatter::NONE</constant>,
|
||
<constant>IntlDateFormatter::SHORT</constant>,
|
||
<constant>IntlDateFormatter::MEDIUM</constant>,
|
||
<constant>IntlDateFormatter::LONG</constant>,
|
||
<constant>IntlDateFormatter::FULL</constant>),
|
||
целое число (<type>int</type>) со значением одной из этих констант (в этом случае оно будет использоваться
|
||
как для времени, так и для даты) или строка (<type>string</type>) в формате,
|
||
описанном в <link xlink:href="&url.icu.dateformat2;">документации ICU</link>.
|
||
Если указано значение &null;, будет использоваться стиль по умолчанию.
|
||
</para>
|
||
</listitem>
|
||
</varlistentry>
|
||
<varlistentry>
|
||
<term><parameter>locale</parameter></term>
|
||
<listitem>
|
||
<para>
|
||
Используемый языковой стандарт или &null; для использования
|
||
<link linkend="ini.intl.default-locale">значения по умолчанию</link>.
|
||
</para>
|
||
</listitem>
|
||
</varlistentry>
|
||
</variablelist>
|
||
</refsect1>
|
||
|
||
<refsect1 role="returnvalues">
|
||
&reftitle.returnvalues;
|
||
<para>
|
||
Строка с результатом&return.falseforfailure;.
|
||
</para>
|
||
</refsect1>
|
||
|
||
|
||
<refsect1 role="examples">
|
||
&reftitle.examples;
|
||
<para>
|
||
<example>
|
||
<title>Пример использования <function>IntlDateFormatter::formatObject</function></title>
|
||
<programlisting role="php">
|
||
<![CDATA[
|
||
<?php
|
||
/* часовой пояс по умолчанию не имеет значения; часовой пояс взят из объекта */
|
||
ini_set('date.timezone', 'UTC');
|
||
/* языковой стандарт по умолчанию берётся из этой настройки ini */
|
||
ini_set('intl.default_locale', 'fr_FR');
|
||
|
||
$cal = IntlCalendar::fromDateTime("2013-06-06 17:05:06 Europe/Dublin");
|
||
echo "По умолчанию:\n\t",
|
||
IntlDateFormatter::formatObject($cal),
|
||
"\n";
|
||
|
||
echo "Полная запись: \$format (full):\n\t",
|
||
IntlDateFormatter::formatObject($cal, IntlDateFormatter::FULL),
|
||
"\n";
|
||
|
||
echo "Массив: \$format (none, full):\n\t",
|
||
IntlDateFormatter::formatObject($cal, array(
|
||
IntlDateFormatter::NONE,
|
||
IntlDateFormatter::FULL)),
|
||
"\n";
|
||
|
||
echo "Строка: \$format (d 'of' MMMM y):\n\t",
|
||
IntlDateFormatter::formatObject($cal, "d 'of' MMMM y", 'en_US'),
|
||
"\n";
|
||
|
||
echo "Объект DateTime:\n\t",
|
||
IntlDateFormatter::formatObject(
|
||
new DateTime("2013-09-09 09:09:09 Europe/Madrid"),
|
||
IntlDateFormatter::FULL,
|
||
'es_ES'),
|
||
"\n";
|
||
|
||
]]>
|
||
</programlisting>
|
||
&example.outputs;
|
||
<screen>
|
||
<![CDATA[
|
||
По умолчанию:
|
||
6 juin 2013 17:05:06
|
||
Полная запись: $format (full):
|
||
jeudi 6 juin 2013 17:05:06 heure d’été irlandaise
|
||
Массив: $format (none, full):
|
||
17:05:06 heure d’été irlandaise
|
||
Строка: $format (d 'of' MMMM y):
|
||
6 of June 2013
|
||
Объект DateTime:
|
||
lunes, 9 de septiembre de 2013 09:09:09 Hora de verano de Europa central
|
||
|
||
]]>
|
||
</screen>
|
||
</example>
|
||
</para>
|
||
</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
|
||
-->
|