IntlDatePatternGenerator::getBestPattern

Determines the most suitable date/time format

&reftitle.description; public ``string``false```IntlDatePatternGenerator::getBestPattern` `string` `skeleton`

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

&reftitle.parameters;

`skeleton`

- The skeleton.

&reftitle.returnvalues;

Returns a format, accepted by `DateTimeInterface::format` on success, &return.falseforfailure;.

&reftitle.examples;

### `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');
    ?>

&example.outputs;

    de: 24.04.2021
    en: 04/24/2021