PHPackages                             stamp/stamp - 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. stamp/stamp

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

stamp/stamp
===========

Easy date formatting for humans

v1.1.0(13y ago)36434MITPHPPHP &gt;=5.3.0

Since Feb 13Pushed 13y ago2 watchersCompare

[ Source](https://github.com/chadcf/stamp)[ Packagist](https://packagist.org/packages/stamp/stamp)[ Docs](http://github.org/chadcf/stamp)[ RSS](/packages/stamp-stamp/feed)WikiDiscussions master Synced yesterday

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

PHP Stamp
=========

[](#php-stamp)

Simple date formatting for humans. Based on the ruby package of the same name, stamp allows you to easily format dates without having to remember arcane arguments to pass to date().

Status
------

[](#status)

Stamp should be fully functional, it passes all the tests that it's ruby cousin does. The code needs a bit of cleanup but it is perfectly usable as is.

Performance
-----------

[](#performance)

Stamp works by parsing the example string and building up an array of formatting objects for each part of the example. This obviously involves creating multiple objects and is thus a heavier solution than just using php's date() function. But, as with most development tools, the tradeoff for slightly decreased performance is easier development.

To help with performance, the parser is cached per example string. You should only create one Stamp object per view/page and reuse it for each date format. Stamp will cache each example string parser so that if you loop through a set of dates and format each using the same example, the example will only be parsed once.

On my MacBook Pro stamp can format 10,000 different dates (using different example strings) in about 0.75 seconds and can format 10,000 different dates (using the same example string) in about 0.2 seconds.

TODO
----

[](#todo)

- Adhere to PSR-2 standards
- Internationalisation?

Usage
-----

[](#usage)

Stamp can be loaded using the Composer autoloader or an autoloader of your choice.

Usage is simple:

```
$stamp = new Stamp\Stamp();
$stamp->stamp("August 14th 2012", time()); // February 9th 2013
$stamp->stamp("04/23/2012 @ 4:13PM (Saturday)", time()) // 02/09/2013 @ 10:50AM (Sunday)
```

For a more complete list of examples, check out the [Test Suite](https://github.com/chadcf/stamp/blob/master/features/stamp.feature)

Limitations
-----------

[](#limitations)

There are some instances where it will be difficult to guess what your example really means, so it is best to supply example strings that are not ambiguous. For example the following example will fail if you intend it to be mm/dd/yyyy:

```
$stamp->stamp("4/5/2012", time());
```

The reason for this is that the information provided makes it impossible to distinguish between m/d/y or d/y/m since both single digit values are valid for both month or day. To avoid this it is best to supply example days &gt; 12 and example months &lt; 12.

###  Health Score

31

—

LowBetter than 66% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 94.4% 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 ~0 days

Total

2

Last Release

4888d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8b3a3135aaedb52f46c2c0562f23ddf868b5a9c930f108f7721a57c6bbb75028?d=identicon)[chadcf](/maintainers/chadcf)

---

Top Contributors

[![gnarfle](https://avatars.githubusercontent.com/u/23989?v=4)](https://github.com/gnarfle "gnarfle (17 commits)")[![baileylo](https://avatars.githubusercontent.com/u/145345?v=4)](https://github.com/baileylo "baileylo (1 commits)")

---

Tags

date

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[rlanvin/php-rrule

Lightweight and fast recurrence rules for PHP (RFC 5545)

70011.9M60](/packages/rlanvin-php-rrule)[knplabs/knp-time-bundle

Making your dates and durations look sensible and descriptive

6339.5M56](/packages/knplabs-knp-time-bundle)[league/period

Time range API for PHP

7335.8M23](/packages/league-period)[morilog/jalali

This Package helps developers to easily work with Jalali (Shamsi or Iranian) dates in PHP applications, based on Jalali (Shamsi) DateTime class.

9391.3M53](/packages/morilog-jalali)[brick/date-time

Date and time library

3663.8M108](/packages/brick-date-time)[aeon-php/calendar

PHP type safe, immutable calendar library

20810.4M16](/packages/aeon-php-calendar)

PHPackages © 2026

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