IntlDateFormatter::formatObject

datefmt_format_object

(PHP 5 >= 5.5.0, PHP 7, PHP 8, PECL intl >= 3.0.0)

IntlDateFormatter::formatObject -- datefmt_format_objectFormats an object

Beschreibung

Objektorientierter Stil

public static IntlDateFormatter::formatObject(IntlCalendar|DateTimeInterface $datetime, array|int|string|null $format = null, ?string $locale = null): string|false

Prozeduraler Stil

datefmt_format_object(IntlCalendar|DateTimeInterface $datetime, array|int|string|null $format = null, ?string $locale = null): string|false

This 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

datetime

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 int 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. If null, the default style will be used.

locale

The locale to use, or null to use the default one.

Rückgabewerte

A string with resultBei einem Fehler wird false zurückgegeben..

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($calIntlDateFormatter::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

Hier Kannst Du einen Kommentar verfassen


Bitte gib mindestens 10 Zeichen ein.
Wird geladen... Bitte warte.
* Pflichtangabe
Es sind noch keine Kommentare vorhanden.

PHP cURL-Tutorial: Verwendung von cURL zum Durchführen von HTTP-Anfragen

cURL ist eine leistungsstarke PHP-Erweiterung, die es Ihnen ermöglicht, mit verschiedenen Servern über verschiedene Protokolle wie HTTP, HTTPS, FTP und mehr zu kommunizieren. ...

TheMax

Autor : TheMax
Kategorie: PHP-Tutorials

Midjourney Tutorial - Anleitung für Anfänger

Über Midjourney, dem Tool zur Erstellung digitaler Bilder mithilfe von künstlicher Intelligenz, gibt es ein informatives Video mit dem Titel "Midjourney Tutorial auf Deutsch - Anleitung für Anfänger" ...

Mike94

Autor : Mike94
Kategorie: KI Tutorials

Grundlagen von Views in MySQL

Views in einer MySQL-Datenbank bieten die Möglichkeit, eine virtuelle Tabelle basierend auf dem Ergebnis einer SQL-Abfrage zu erstellen. ...

admin

Autor : admin
Kategorie: mySQL-Tutorials

Tutorial veröffentlichen

Tutorial veröffentlichen

Teile Dein Wissen mit anderen Entwicklern weltweit

Du bist Profi in deinem Bereich und möchtest dein Wissen teilen, dann melde dich jetzt an und teile es mit unserer PHP-Community

mehr erfahren

Tutorial veröffentlichen

SoundCloud to MP3

SoundCloud (https://soundcloudto.com/) to MP3 converters have gained popularity as convenient tools for downloading and converting audio from Soun ...

Geschrieben von soundcloudto am 19.07.2024 04:10:40
Forum: User pages
Suche Netzwerktechnik Großhändler

I'm currently seeking reliable wholesalers specializing in network technology. Please provide details on your range of products, pricing, and any ...

Geschrieben von dussan77 am 12.07.2024 16:54:48
Forum: Ankündigungen
Getting Database Connection Failed Error in PHP Project

Hi everyone, I’m currently working on an AI and ML-based web application using PHP, and I've hit a roadblock. I’m encountering a “Database ...

Geschrieben von Gast am 27.06.2024 11:31:32
Forum: Off-Topic Diskussionen
How to overcome Safari's iframe cookie block?

Hello I think your cookies are set with SameSite=None; Secure to allow cross-site usage. To implement a custom proxy on the server side to handle ...

Geschrieben von Gast am 27.06.2024 11:04:46
Forum: HTML, JavaScript, AJAX, jQuery, CSS, Bootstrap, LESS