1. Go to this page and download the library: Download sunkan/dictus library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
sunkan / dictus example snippets
use Sunkan\Dictus\DateTimeFormat;
use Sunkan\Dictus\DateTimeFormatter;
use Sunkan\Dictus\LocalizedFormat;
use Sunkan\Dictus\LocalizedStrftimeFormatter;
use Sunkan\Dictus\LocalizedDateTimeFormatter;
LocalizedDateTimeFormatter::addLocaleFormat('sv_SE', new \Sunkan\Dictus\Locales\SvSe());
$jsonDateFormatter = new DateTimeFormatter(DateTimeFormat::JSON);
$localizedStrftimeFormatter = new LocalizedStrftimeFormatter('sv_SE', LocalizedFormat::DATETIME);
$localizedDateTimeFormatter = new LocalizedDateTimeFormatter('sv_SE', 'l d F [kl.] H:i');
$date = new DateTimeImmutable();
echo $jsonDateFormatter->format($date);
echo $localizedStrftimeFormatterFormatter->format($date); // 21.08.2023 16:26
echo $localizedDateTimeFormatter->format($date); // måndag 21 augusti kl. 16:26
'LT' => 'H:i', // 17:32
'LTS' => 'H:i:s', // 17:32:12
'L' => 'd.m.Y', // 06.12.2023
'LL' => 'j. F Y', // 6. desember 2023
'LLL' => 'j. F [kl.] H:i', // 6. desember kl. 17:32
'LLLL' => 'l j. F Y [kl.] H:i', // miðvikudagur 6. desember 2023 kl. 17:32
final class CustomLocal implements \Sunkan\Dictus\LocaleFormat
{
public function formatChar(string $char, \DateTimeImmutable $dateTime): ?string
{
return match ($char) {
'D' => 'short custom weekday name',
'l' => 'long custom weekday name',
'M' => null, // use english month names
'F' => null, // use english month names
default => null,
};
}
public function resolveFormat(string $format): ?string
{
return match($format) {
'LT' => 'H:i', // can be any valid date format string
'LTS' => 'H:i:s', // can be any valid date format string
'L' => 'd.m.Y', // can be any valid date format string
'LL' => 'j. F Y', // can be any valid date format string
'LLL' => 'j. F [kl.] H:i', // can be any valid date format string
'LLLL' => 'l j. F Y [kl.] H:i', // can be any valid date format string
default => null,
};
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.