PHPackages                             ivandokov/fluentdate - 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. ivandokov/fluentdate

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

ivandokov/fluentdate
====================

Library to format PHP dates

1.0.0(5y ago)1652MITPHPPHP ^7.4.0

Since Oct 13Pushed 5y ago1 watchersCompare

[ Source](https://github.com/ivandokov/fluentdate)[ Packagist](https://packagist.org/packages/ivandokov/fluentdate)[ RSS](/packages/ivandokov-fluentdate/feed)WikiDiscussions master Synced 4d ago

READMEChangelogDependencies (2)Versions (2)Used By (0)

FluentDate
==========

[](#fluentdate)

[![Tests Action Status](https://github.com/ivandokov/fluentdate/workflows/Tests/badge.svg)](https://github.com/ivandokov/fluentdate/actions)[![Packagist PHP Version Support](https://camo.githubusercontent.com/2f222a952cc9ffad2f59c3b84338509b196727b6f38d8929c1c96e01da69e720/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6976616e646f6b6f762f666c75656e7464617465)](https://packagist.org/packages/ivandokov/fluentdate)[![Packagist Version](https://camo.githubusercontent.com/83e85e63d587303f72f896d7ecb4df9f1e7604e3c0981e31fe1defd7110b3654/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6976616e646f6b6f762f666c75656e7464617465)](https://packagist.org/packages/ivandokov/fluentdate)[![Packagist Downloads](https://camo.githubusercontent.com/7a87e5970928601ccc3eb9de16b1517ae1662468bb355fcd77cfc826128cfcec/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f6976616e646f6b6f762f666c75656e7464617465)](https://packagist.org/packages/ivandokov/fluentdate)[![Packagist License](https://camo.githubusercontent.com/072ae2a359a23d9c1c15f68a1d4e7131b2138880b33b533f2551d1320ac9cca1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6976616e646f6b6f762f666c75656e7464617465)](https://packagist.org/packages/ivandokov/fluentdate)

Format PHP dates with ease. You don't have to Google the [format](https://www.php.net/manual/en/datetime.format.php) string each time. Use plain English to set the format, almost as you pronounce it.

Installation
------------

[](#installation)

```
composer require ivandokov/fluentdate
```

How to use
----------

[](#how-to-use)

For full details of how to use the library please take a look at our [tests](tests/FluentDateTest.php).

### Format string

[](#format-string)

Any string that can be parsed by `DateTime` class can be used.

```
$date = FluentDate::forString('now')
    ->year(new YearFourDigits())
    ->separator(new SeparatorDot())
    ->month(new MonthTwoDigitsWithLeadingZeros())
    ->separator(new SeparatorDot())
    ->day(new DayWithLeadingZero());

echo "Today is $date";
//    Today is 2020.10.09
```

### Format DateTime

[](#format-datetime)

```
$datetime = new DateTime('now'); // The DateTime you want to format
$date = FluentDate::forDateTime($datetime)
    ->year(new YearFourDigits())
    ->separator(new SeparatorDot())
    ->month(new MonthTwoDigitsWithLeadingZeros())
    ->separator(new SeparatorDot())
    ->day(new DayWithLeadingZero());

echo "Today is $date";
//    Today is 2020.10.09
```

The `$date` can be directly used in strings since it implements `__toString()` magic method but if you want you can use the `->toString()` method.

### The format string

[](#the-format-string)

If you want to get the underlying date format string you can use the `->toFormat()` method like this:

```
$datetime = new DateTime('01.03.2020 00:00:00');
$dateFormat = FluentDate::forDateTime($datetime)
    ->year(new YearFourDigits())
    ->separator(new SeparatorDot())
    ->month(new MonthTwoDigitsWithLeadingZeros())
    ->separator(new SeparatorDot())
    ->day(new DayWithLeadingZero())
    ->toFormat();
// Y.m.d
```

### Format Carbon

[](#format-carbon)

If you want to format a [Carbon](https://carbon.nesbot.com/) instance you can use the same method described above since Carbon is extending `DateTime`.

```
$carbon = Carbon::now();
$date = FluentDate::forDateTime($carbon)
    ->year(new YearFourDigits())
    ->separator(new SeparatorDot())
    ->month(new MonthTwoDigitsWithLeadingZeros())
    ->separator(new SeparatorDot())
    ->day(new DayWithLeadingZero())
    ->toString();
// 2020.10.09
```

Available formats
-----------------

[](#available-formats)

The format classes are self explanatory by their class names so you can take a look at all available classes in the [Formats](src/Formats) directory.

Separators
----------

[](#separators)

We support the most common separators for dates but also a custom string separator in case of need.

- `IvanDokov\FluentDate\Formats\SeparatorDot`
- `IvanDokov\FluentDate\Formats\SeparatorDash`
- `IvanDokov\FluentDate\Formats\SeparatorForwardSlash`
- `IvanDokov\FluentDate\Formats\SeparatorSpace`
- `IvanDokov\FluentDate\Formats\SeparatorColon`
- `IvanDokov\FluentDate\Formats\SeparatorString`

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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

Unknown

Total

1

Last Release

2041d ago

### Community

Maintainers

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

---

Top Contributors

[![ivandokov](https://avatars.githubusercontent.com/u/2357455?v=4)](https://github.com/ivandokov "ivandokov (14 commits)")

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/ivandokov-fluentdate/health.svg)

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

###  Alternatives

[illuminate/conditionable

The Illuminate Conditionable package.

9043.1M32](/packages/illuminate-conditionable)[leedavis81/vent

PHP variable events.

814.6k](/packages/leedavis81-vent)[codingfreaks/cf-cookiemanager

Manage cookies, scripts, and GDPR compliance on your Typo3 website with CodingFreaks Typo3 Cookie Manager. Customize cookie banners, streamline workflow, and enhance user experience. Ensure GDPR compliance and take control of cookie management with our Typo3 cookie management extension. Visit the official Typo3 Documentation page to learn more.

1625.8k](/packages/codingfreaks-cf-cookiemanager)

PHPackages © 2026

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