php-doc-en/reference/datetime/datetimeinterface/format.xml
2013-05-17 18:17:21 +00:00

127 lines
3.4 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="datetime.format" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>DateTime::format</refname>
<refname>DateTimeImmutable::format</refname>
<refname>DateTimeInterface::format</refname>
<refname>date_format</refname>
<refpurpose>Returns date formatted according to given format</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<para>&style.oop;</para>
<methodsynopsis role="oop">
<modifier>public</modifier> <type>string</type><methodname>DateTime::format</methodname>
<methodparam><type>string</type><parameter>format</parameter></methodparam>
</methodsynopsis>
<methodsynopsis role="DateTimeImmutable">
<modifier>public</modifier> <type>string</type><methodname>DateTimeImmutable::format</methodname>
<methodparam><type>string</type><parameter>format</parameter></methodparam>
</methodsynopsis>
<methodsynopsis role="DateTimeInterface">
<modifier>public</modifier> <type>string</type><methodname>DateTimeInterface::format</methodname>
<methodparam><type>string</type><parameter>format</parameter></methodparam>
</methodsynopsis>
<para>&style.procedural;</para>
<methodsynopsis role="procedural">
<type>string</type><methodname>date_format</methodname>
<methodparam><type>DateTimeInterface</type><parameter>object</parameter></methodparam>
<methodparam><type>string</type><parameter>format</parameter></methodparam>
</methodsynopsis>
<para>
Returns date formatted according to given format.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<variablelist>
&date.datetime.description;
<varlistentry>
<term><parameter>format</parameter></term>
<listitem>
<para>
Format accepted by <function>date</function>.
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Returns the formatted date string on success&return.falseforfailure;.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<example>
<title><function>DateTime::format</function> example</title>
<para>&style.oop;</para>
<programlisting role="php">
<![CDATA[
<?php
$date = new DateTime('2000-01-01');
echo $date->format('Y-m-d H:i:s');
?>
]]>
</programlisting>
<para>&style.procedural;</para>
<programlisting role="php">
<![CDATA[
<?php
$date = date_create('2000-01-01');
echo date_format($date, 'Y-m-d H:i:s');
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
2000-01-01 00:00:00
]]>
</screen>
</example>
</refsect1>
<refsect1 role="notes">
&reftitle.notes;
<para>
This method does not use locales. All output is in English.
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<simplelist>
<member><function>date</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
-->