IntlDateFormatter: : formatObject
datefmt_format_object
(PHP 5 >= 5.5.0, PHP 7, PECL intl >= 3.0.0)
IntlDateFormatter::formatObject -- datefmt_format_object — Formats an object
Beschreibung
Objektorientierter Stil
$object
[, mixed $format
= NULL
[, string $locale
= NULL
]] ) : stringProzeduraler Stil
$object
[, mixed $format
= NULL
[, string $locale
= NULL
]] ) : stringThis function allows formatting an IntlCalendar or DateTime object without first explicitly creating a IntlDateFormatter object.
The temporary IntlDateFormatter that will be created will take the timezone from the passed in object. The timezone database bundled with PHP will not be used – ICU's will be used instead. The timezone identifier used in DateTime objects must therefore also exist in ICU's database.
Parameter-Liste
-
object
-
An object of type IntlCalendar or DateTime. The timezone information in the object will be used.
-
format
-
How to format the date/time. This can either be an array with two elements (first the date style, then the time style, these being one of the constants
IntlDateFormatter::NONE
,IntlDateFormatter::SHORT
,IntlDateFormatter::MEDIUM
,IntlDateFormatter::LONG
,IntlDateFormatter::FULL
), an integer with the value of one of these constants (in which case it will be used both for the time and the date) or a string with the format described in » the ICU documentation. IfNULL
, the default style will be used. -
locale
-
The locale to use, or
NULL
to use the default one.
Beispiele
Beispiel #1 IntlDateFormatter::formatObject() examples
<?php
/* default timezone is irrelevant; timezone taken from the object */
ini_set('date.timezone', 'UTC');
/* default locale is taken from this ini setting */
ini_set('intl.default_locale', 'fr_FR');
$cal = IntlCalendar::fromDateTime("2013-06-06 17:05:06 Europe/Dublin");
echo "default:\n\t",
IntlDateFormatter::formatObject($cal),
"\n";
echo "long \$format (full):\n\t",
IntlDateFormatter::formatObject($cal, IntlDateFormatter::FULL),
"\n";
echo "array \$format (none, full):\n\t",
IntlDateFormatter::formatObject($cal, array(
IntlDateFormatter::NONE,
IntlDateFormatter::FULL)),
"\n";
echo "string \$format (d 'of' MMMM y):\n\t",
IntlDateFormatter::formatObject($cal, "d 'of' MMMM y", 'en_US'),
"\n";
echo "with DateTime:\n\t",
IntlDateFormatter::formatObject(
new DateTime("2013-09-09 09:09:09 Europe/Madrid"),
IntlDateFormatter::FULL,
'es_ES'),
"\n";
Das oben gezeigte Beispiel erzeugt folgende Ausgabe:
default: 6 juin 2013 17:05:06 long $format (full): jeudi 6 juin 2013 17:05:06 heure d’été irlandaise array $format (none, full): 17:05:06 heure d’été irlandaise string $format (d 'of' MMMM y): 6 of June 2013 with DateTime: lunes, 9 de septiembre de 2013 09:09:09 Hora de verano de Europa central
Deutsche Übersetzung
Sie haben gebeten, diese Seite auf Deutsch zu besuchen. Momentan ist nur die Oberfläche übersetzt, aber noch nicht der gesamte Inhalt.Wenn Sie mir bei Übersetzungen helfen wollen, ist Ihr Beitrag willkommen. Alles, was Sie tun müssen, ist, sich auf der Website zu registrieren und mir eine Nachricht zu schicken, in der Sie gebeten werden, Sie der Gruppe der Übersetzer hinzuzufügen, die Ihnen die Möglichkeit gibt, die gewünschten Seiten zu übersetzen. Ein Link am Ende jeder übersetzten Seite zeigt an, dass Sie der Übersetzer sind und einen Link zu Ihrem Profil haben.
Vielen Dank im Voraus.
Dokument erstellt 30/01/2003, zuletzt geändert 26/10/2018
Quelle des gedruckten Dokuments:https://www.gaudry.be/de/php-rf-intldateformatter.formatobject.html
Die Infobro ist eine persönliche Seite, deren Inhalt in meiner alleinigen Verantwortung liegt. Der Text ist unter der CreativeCommons-Lizenz (BY-NC-SA) verfügbar. Weitere Informationen auf die Nutzungsbedingungen und dem Autor.
Referenzen
Diese Verweise und Links verweisen auf Dokumente, die während des Schreibens dieser Seite konsultiert wurden, oder die zusätzliche Informationen liefern können, aber die Autoren dieser Quellen können nicht für den Inhalt dieser Seite verantwortlich gemacht werden.
Der Autor Diese Website ist allein dafür verantwortlich, wie die verschiedenen Konzepte und Freiheiten, die mit den Nachschlagewerken gemacht werden, hier dargestellt werden. Denken Sie daran, dass Sie mehrere Quellinformationen austauschen müssen, um das Risiko von Fehlern zu reduzieren.