PHPackages                             indieweb/date-formatter - 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. indieweb/date-formatter

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

indieweb/date-formatter
=======================

Render dates and date ranges in a human-readable format, including proper microformats-2 markup

0.3.1(10y ago)1919.7k1[2 issues](https://github.com/indieweb/date-formatter-php/issues)Apache-2.0PHPPHP &gt;=5.3.0

Since Jul 7Pushed 10y ago11 watchersCompare

[ Source](https://github.com/indieweb/date-formatter-php)[ Packagist](https://packagist.org/packages/indieweb/date-formatter)[ Docs](https://github.com/indieweb/date-formatter-php)[ RSS](/packages/indieweb-date-formatter/feed)WikiDiscussions master Synced 1mo ago

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

Date Formatter
==============

[](#date-formatter)

Render dates and date ranges in a human-readable format, including proper microformats-2 markup.

[![Build Status](https://camo.githubusercontent.com/2758ca760e999c9b584834f1d339a7b321f3080fb42738ad2217919f3206d2ed/68747470733a2f2f7472617669732d63692e6f72672f696e6469657765622f646174652d666f726d61747465722d7068702e7376673f6272616e63683d6d6173746572)](http://travis-ci.org/indieweb/date-formatter-php)

Usage
-----

[](#usage)

### Date Range with Time

[](#date-range-with-time)

```
echo IndieWeb\DateFormatter::format('2013-10-08T07:00:00-07:00', '2013-10-08T17:00:00-07:00');
```

outputs

```

  October 8, 2013 from 7:00am

to

  5:00pm (-0700)

```

(whitespace added for readability)

which displays in a browser as

```
October 8, 2013 from 7:00am to 5:00pm (-0700)

```

### Date Range with No Time

[](#date-range-with-no-time)

```
echo IndieWeb\DateFormatter::format('2013-10-08', '2013-10-11');
```

outputs

```

  October 8

-

  11, 2013

```

which displays in a browser as

```
October 8-11, 2013

```

Other Examples
--------------

[](#other-examples)

This example shows how progressively more data is added to the output as the start and end dates have less in common with each other.

```
use IndieWeb\DateFormatter;

echo DateFormatter::format('2013-09-03', '2013-09-08');
// September 3-8, 2013

echo DateFormatter::format('2013-09-28', '2013-10-03');
// September 28 through October 3, 2013

echo DateFormatter::format('2013-12-30', '2014-01-02');
// December 30, 2013 through January 2, 2014
```

Here are similar examples when the dates include times as well.

```
use IndieWeb\DateFormatter;

echo DateFormatter::format('2013-10-08T07:00:00-07:00', '2013-10-08T17:00:00-07:00');
// October 8, 2013 from 7:00am to 5:00pm (-0700)

echo DateFormatter::format('2013-10-08T07:00:00-07:00', '2013-10-10T17:00:00-07:00');
// October 8, 2013 at 7:00am until Oct 10 at 5:00pm (-0700)

echo DateFormatter::format('2013-08-31T07:00:00-07:00', '2013-09-01T17:00:00-07:00');
// August 31, 2013 7:00am until September 1 at 5:00pm (-0700)

echo DateFormatter::format('2013-12-31T07:00:00-07:00', '2014-01-01T17:00:00-07:00');
// December 31, 2013 7:00am until January 1, 2014 5:00pm (-0700)
```

Alternate Class Names
---------------------

[](#alternate-class-names)

If you want the HTML to include Microformats classes other than "dt-start" and "dt-end", you can pass class names as additional parameters.

```
echo IndieWeb\DateFormatter::format('2013-10-08T07:00:00-0700', '2013-10-08T08:50:00-0700', 'dt-departure', 'dt-arrival');
```

```

  October 8, 2013 from 7:00am

to

  8:50am (-0700)

```

Tests
-----

[](#tests)

Please see the [tests](tests/BasicTest.php) for more complete examples of different output formats.

Future Enhancements
-------------------

[](#future-enhancements)

- Optionally also display the day of the week in date range output
- Option to use short month names instead of full names
- Make the parser more tolerant of other input formats

If you see other input or output formats you would like handled, please open an Issue with a description. Bonus points if you write it as a test case:

```
  public function testDescriptionOfWhatYoureTesting() {
    $this->_testEquals('Final Text Output', 'start-date', 'end-date');
  }
```

License
-------

[](#license)

Copyright 2015 by Aaron Parecki

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity31

Limited adoption so far

Community11

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

Every ~125 days

Recently: every ~222 days

Total

9

Last Release

3695d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/385b302aef27e9e72ddfbf65c8b15cfce5946744fe2e541c5b415665fc2351fc?d=identicon)[aaronpk](/maintainers/aaronpk)

---

Top Contributors

[![aaronpk](https://avatars.githubusercontent.com/u/113001?v=4)](https://github.com/aaronpk "aaronpk (27 commits)")

---

Tags

formatdatemicroformatsmicroformats2

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/indieweb-date-formatter/health.svg)

```
[![Health](https://phpackages.com/badges/indieweb-date-formatter/health.svg)](https://phpackages.com/packages/indieweb-date-formatter)
```

###  Alternatives

[willdurand/negotiation

Content Negotiation tools for PHP provided as a standalone library.

1.4k122.0M157](/packages/willdurand-negotiation)[rlanvin/php-rrule

Lightweight and fast recurrence rules for PHP (RFC 5545)

69810.6M39](/packages/rlanvin-php-rrule)[kartik-v/yii2-datecontrol

Date control module allowing separation of formats for View and Model for Yii Framework 2.0

551.5M36](/packages/kartik-v-yii2-datecontrol)

PHPackages © 2026

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