IntlDatePatternGenerator::getBestPattern

(PHP 8 >= 8.1.0)

IntlDatePatternGenerator::getBestPatternDetermines the most suitable date/time format

Descrizione

public IntlDatePatternGenerator::getBestPattern(string $skeleton): string|false

Determines which date/time format is most suitable for a particular locale.

Elenco dei parametri

skeleton

The skeleton.

Valori restituiti

Returns a format, accepted by DateTimeInterface::format() on success, o false in caso di fallimento.

Esempi

Example #1 IntlDatePatternGenerator::getBestPattern() example

<?php

$skeleton 
'YYYYMMdd';
$today = \DateTimeImmutable::createFromFormat('Y-m-d''2021-04-24');
 
$patternGenerator = new \IntlDatePatternGenerator('de_DE');
$pattern $patternGenerator->getBestPattern($skeleton);
echo 
'de: ', \IntlDateFormatter::formatObject($today$pattern'de_DE'), "\n";
 
$patternGenerator = new \IntlDatePatternGenerator('en_US');
$pattern $patternGenerator->getBestPattern($skeleton);
echo 
'en: ', \IntlDateFormatter::formatObject($today$pattern'en_US');
?>

Il precedente esempio visualizzerĂ :

de: 24.04.2021
en: 04/24/2021

add a note add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top