PHPackages                             sunkan/dictus - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. sunkan/dictus

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

sunkan/dictus
=============

Date utility classes

2.8.0(3mo ago)217.1k↓43.5%12MITPHPPHP ^8.0CI passing

Since May 27Pushed 3mo ago2 watchersCompare

[ Source](https://github.com/sunkan/dictus)[ Packagist](https://packagist.org/packages/sunkan/dictus)[ RSS](/packages/sunkan-dictus/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (4)Versions (26)Used By (2)

Sunkan Dictus - Date utility
============================

[](#sunkan-dictus---date-utility)

[![Latest Version](https://camo.githubusercontent.com/a5d95d2bbfbcb3853b0d6c14dc0eb59f8f5476f27ac86c215526797bd5ede04e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f73756e6b616e2f6469637475732e7376673f7374796c653d666c61742d737175617265)](https://github.com/sunkan/dictus/releases)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)

This is a small library to help with date formatting and keeping a consistent clock in a project

Usage
-----

[](#usage)

### Using formatters

[](#using-formatters)

```
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
```

### Using localized formatters

[](#using-localized-formatters)

We recommend using `LocalizedDateTimeFormatter` that just support translating of the regular [date format syntax](https://www.php.net/manual/en/datetime.format.php#refsect1-datetime.format-parameters).

It will translate the following keys:

- `D` short version of day name
- `l` long version of day name
- `M` short version of month name
- `F` long version of month name

It also supports 6 custom keys that helps with common localized formats

Example for icelandic

```
'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
```

#### Custom localization

[](#custom-localization)

All you need to do to create your own localization is to create a class that's implements `LocaleFormat`

```
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,
		};
	}
}
```

### Clock

[](#clock)

The library provides 3 clock implementations

`SystemClock, FrozenClock and ProjectClock`

`SystemClock` is just a wrapper around `new DateTimeImmutable('now')`

`FrozenClock` is a wrapper around a fixed `DateTimeImmutable` object

`ProjectClock` is wrapper around a `ClockInterface` implementation

###  Health Score

51

—

FairBetter than 96% of packages

Maintenance79

Regular maintenance activity

Popularity30

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 71.2% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~81 days

Recently: every ~153 days

Total

22

Last Release

109d ago

Major Versions

0.2.0 → 1.0.02022-05-03

1.6.0 → 2.0.02023-01-03

### Community

Maintainers

![](https://www.gravatar.com/avatar/ce9d40996574fd1f18f69556c872c6eb94e59977c5f0b33c9df541d82fbb3800?d=identicon)[sunkan](/maintainers/sunkan)

---

Top Contributors

[![sunkan](https://avatars.githubusercontent.com/u/568492?v=4)](https://github.com/sunkan "sunkan (42 commits)")[![bix0r](https://avatars.githubusercontent.com/u/2131100?v=4)](https://github.com/bix0r "bix0r (17 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/sunkan-dictus/health.svg)

```
[![Health](https://phpackages.com/badges/sunkan-dictus/health.svg)](https://phpackages.com/packages/sunkan-dictus)
```

###  Alternatives

[lcobucci/clock

Yet another clock abstraction

790190.9M114](/packages/lcobucci-clock)[symfony/clock

Decouples applications from the system clock

430168.9M205](/packages/symfony-clock)[eventsauce/eventsauce

A pragmatic event sourcing library for PHP with a focus on developer experience.

8632.1M47](/packages/eventsauce-eventsauce)[ecotone/ecotone

Supporting you in building DDD, CQRS, Event Sourcing applications with ease.

558549.8k17](/packages/ecotone-ecotone)[mcp/sdk

Model Context Protocol SDK for Client and Server applications in PHP

1.4k423.9k30](/packages/mcp-sdk)[flow-php/etl

PHP ETL - Extract Transform Load - Abstraction

374468.4k51](/packages/flow-php-etl)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
