PHPackages                             romeoz/rock-date - 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. [Localization &amp; i18n](/categories/localization)
4. /
5. romeoz/rock-date

ActiveLibrary[Localization &amp; i18n](/categories/localization)

romeoz/rock-date
================

A simple DateTime library for PHP with I18N

0.12.0(10y ago)02.5k4MITPHPPHP &gt;=5.4.0

Since Mar 4Pushed 10y ago1 watchersCompare

[ Source](https://github.com/romeOz/rock-date)[ Packagist](https://packagist.org/packages/romeoz/rock-date)[ RSS](/packages/romeoz-rock-date/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (8)Dependencies (2)Versions (9)Used By (4)

A simple DateTime library for PHP
=================================

[](#a-simple-datetime-library-for-php)

[![Latest Stable Version](https://camo.githubusercontent.com/61f809115b6ae29a8fda1f1b75f5c20fa0586205d1fde5dcf7c4d595743b7ab9/68747470733a2f2f706f7365722e707567782e6f72672f726f6d654f7a2f726f636b2d646174652f762f737461626c652e737667)](https://packagist.org/packages/romeOz/rock-date)[![Total Downloads](https://camo.githubusercontent.com/25b772df907c755d2f4b39d2a5492a775fee1fd2ff17edb2fc13979823893542/68747470733a2f2f706f7365722e707567782e6f72672f726f6d654f7a2f726f636b2d646174652f646f776e6c6f6164732e737667)](https://packagist.org/packages/romeOz/rock-date)[![Build Status](https://camo.githubusercontent.com/34dd19e53082686b57148f1b16e89c31731e376957c838998fa87cf6e912ee30/68747470733a2f2f7472617669732d63692e6f72672f726f6d654f7a2f726f636b2d646174652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/romeOz/rock-date)[![HHVM Status](https://camo.githubusercontent.com/200b6dc7c712bc04364650e902468cc738cfca50d0039455ba31faef8fda86af/687474703a2f2f6868766d2e683463632e64652f62616467652f726f6d656f7a2f726f636b2d646174652e737667)](http://hhvm.h4cc.de/package/romeoz/rock-date)[![Coverage Status](https://camo.githubusercontent.com/a6b34b248a888c6ff9fcdd19c1e0c574326ba04a359650d7a952339f8d093e31/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f726f6d654f7a2f726f636b2d646174652f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/r/romeOz/rock-date?branch=master)[![License](https://camo.githubusercontent.com/f00384155117964a189538d0ce5e389c36ce6bc83774d0a3b4e10dcb772775ff/68747470733a2f2f706f7365722e707567782e6f72672f726f6d654f7a2f726f636b2d646174652f6c6963656e73652e737667)](https://packagist.org/packages/romeOz/rock-date)

Features
--------

[](#features)

- Supports many formats (`m/d/Y`, `m/d/Y g:i A` and other)
- Customization of formats and options
- i18n support
- Extended DateInterval (support total months/weeks/hours/minutes/seconds between a dates)
- Standalone module/component for [Rock Framework](https://github.com/romeOz/rock)

Table of Contents
-----------------

[](#table-of-contents)

- [Installation](#installation)
- [Quick Start](#quick-start)
- [Custom format](#custom-format)
- [Custom option format](#custom-option-format)
- [i18n](#i18n)
- [Difference/Interval between a dates](#differenceinterval-between-a-dates)
- [Documentation](#documentation)
- [Requirements](#requirements)

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

[](#installation)

From the Command Line:

```
composer require romeoz/rock-date

```

In your composer.json:

```
{
    "require": {
        "romeoz/rock-date": "*"
    }
}
```

Quick Start
-----------

[](#quick-start)

```
use rock\date\DateTime;

(new DateTime)->format(); // output: current date in the format Y-m-d H:i:s

// default format
(new DateTime)->isoDate(); // output: current date in the format Y-m-d

// modify date
DateTime::set('1988-11-12')->date(); //output: 11/12/1988
```

Custom format
-------------

[](#custom-format)

```
$datetime = DateTime::set('1988-11-12');
$datetime->setFormats(['shortDate' => 'j / F / Y']);

$datetime->shortDate(); // output: 12 / November / 1988
```

Custom option format
--------------------

[](#custom-option-format)

```
$datetime = new DateTime('1988-11-12');
$datetime->setFormatOption('ago', function (DateTime $datetime) {
    return floor((time() - $datetime->getTimestamp()) / 86400) . ' days ago';
});

$datetime->format('d F Y, ago'); // output: 12 November 1988, 9574 days ago
```

i18n
----

[](#i18n)

```
$dateTime = new DateTime('1988-11-12');
$dateTime->setLocale('ru');

$dateTime->format('j  F  Y'); // output: 12  ноября  1988
```

Difference/Interval between a dates
-----------------------------------

[](#differenceinterval-between-a-dates)

```
$diff = (new DateTime('2012-02-01'))->diff(new DateTime('2015-01-01'));

echo $diff->total_months; // output: 36
echo $diff->format('%R%tm months'); // output: +36 months
```

Added additional placeholders:

- `%tm` - total months
- `%tw` - total weeks
- `%th` - total hours
- `%ti` - total minutes
- `%ts` - total seconds

Documentation
-------------

[](#documentation)

- [Custom locales](https://github.com/romeOz/rock-date/blob/master/docs/custom-locales.md)

Requirements
------------

[](#requirements)

- **PHP 5.4+**

License
-------

[](#license)

The DateTime library is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT).

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity53

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 ~35 days

Total

8

Last Release

3844d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/23c5d84a59845d751cb69f5469986579b9312c54c898b366fefdc05baaa80a9c?d=identicon)[romeOz](/maintainers/romeOz)

---

Top Contributors

[![romeOz](https://avatars.githubusercontent.com/u/3135712?v=4)](https://github.com/romeOz "romeOz (31 commits)")

---

Tags

i18ndatetimedate

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/romeoz-rock-date/health.svg)

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

###  Alternatives

[moment/moment

Parse, validate, manipulate, and display dates in JavaScript.

48.1k2.1M37](/packages/moment-moment)[jenssegers/date

A date library to help you work with dates in different languages

1.8k11.2M80](/packages/jenssegers-date)[timrwood/moment

Parse, validate, manipulate, and display dates in JavaScript.

48.0k17.2k](/packages/timrwood-moment)[nesbot/carbon

An API extension for DateTime that supports 281 different languages.

169661.4M4.8k](/packages/nesbot-carbon)[fightbulc/moment

Parse, validate, manipulate, and display dates in PHP w/ i18n support. Inspired by moment.js

9693.2M10](/packages/fightbulc-moment)[punic/punic

PHP-Unicode CLDR

1542.9M29](/packages/punic-punic)

PHPackages © 2026

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