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

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

datetime/datetime
=================

A libary to handle dates and times separately from one another.

0.1.0(7y ago)3285[1 PRs](https://github.com/DateAndTime4PHP/DateTime/pulls)MITPHPPHP ^7.2

Since Jul 11Pushed 7y ago2 watchersCompare

[ Source](https://github.com/DateAndTime4PHP/DateTime)[ Packagist](https://packagist.org/packages/datetime/datetime)[ RSS](/packages/datetime-datetime/feed)WikiDiscussions master Synced 2d ago

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

DateTime
========

[](#datetime)

A libary to handle dates and times separately from one another.

[![Latest Stable Version](https://camo.githubusercontent.com/137e76b55b913cb2ac2a12cc224462e9c92458f571ec4a664b515bacd8d20397/68747470733a2f2f706f7365722e707567782e6f72672f6461746574696d652f6461746574696d652f762f737461626c65)](https://packagist.org/packages/datetime/datetime)[![License](https://camo.githubusercontent.com/cfecbbe93fd796730552f8202fd3e5feb8eaf073f794075cd2cb3e5101a9d3ab/68747470733a2f2f706f7365722e707567782e6f72672f6461746574696d652f6461746574696d652f6c6963656e7365)](https://packagist.org/packages/datetime/datetime)[![Build Status](https://camo.githubusercontent.com/17e3410c0744b0104b5a146e580b2c79632066c6506e5cf67c8f8e4e0d9c91c0/68747470733a2f2f7472617669732d63692e636f6d2f44617465416e6454696d65345048502f4461746554696d652e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/DateAndTime4PHP/DateTime)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/fe5440a1a7add269670f20f9d33947c5c30b371d6527370d3d52e279b8f552cd/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f44617465416e6454696d65345048502f4461746554696d652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/DateAndTime4PHP/DateTime/?branch=master)[![Coverage Status](https://camo.githubusercontent.com/5bbfa372ea49c54051524589f91eb2146d9b80f02e634e265324af468654da16/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f44617465416e6454696d65345048502f4461746554696d652f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/DateAndTime4PHP/DateTime?branch=master)

Background
----------

[](#background)

So far all the libraries around that help handling Dates and Times all extend one of PHPs DateTime-Objects.

This library tries to address that by providing two separate Objects that handle Dates and Times respectively. Internaly they do use PHPs DateTimeImmutable-Object but that's not exposed to the outside.

So now you can use a Date-Object without having to worry about the time-component and vice-versa.

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

[](#installation)

This library is best installed using composer.

```
composer require datetime/datetime
```

Usage
-----

[](#usage)

### Date

[](#date)

There is a `Date`-Object as well as a `DateInterval`-Object

Easiest usage is like this:

```
$date = new \DateTime\Date('2018-07-05');
echo $date->format('d. m. Y');
// 05. 07. 2018
echo $date->format('jS \o\f F Y H:i:s');
// 5th of July 2018 H:i:s
```

Another possibility would be to use it like this:

```
$date = new \DateTime\Date('last wednesday of june 2018');
echo $date->format('d. m. Y');
// 27. 06. 2018
```

Or to use the `DateInterval`-Object:

```
$date1 = new \DateTime\Date('2018-07-05');
$date2 = new \DateTime\Date('2020-07-05');
$interval = $date1->diff($date2);

echo $interval->format('%d %m %y');
// 731 0 0
```

### Time

[](#time)

There is also a `Time`-Object as well as a `TimeInterval`-Object

Those can be used as follows:

```
$time = new \DateTime\Time('12:23:34');
echo $time->format('H:i:s');
// 12:23:34
echo $time->format('jS \o\f F Y H:i:s');
// jS of F Y 12:23:34
```

###  Health Score

25

—

LowBetter than 35% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity49

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

2912d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5ae5183aaad2bc7453230704bd6991dc6ccbcd6e775c6a29efdc94350a69f247?d=identicon)[heiglandreas](/maintainers/heiglandreas)

---

Top Contributors

[![heiglandreas](https://avatars.githubusercontent.com/u/91998?v=4)](https://github.com/heiglandreas "heiglandreas (18 commits)")

---

Tags

datedatetimephpphp7time

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[gbrock/laravel-table

Table functionality for Laravel models

7645.2k](/packages/gbrock-laravel-table)[hyperf/engine-swow

Coroutine engine provided by swow.

1744.6k8](/packages/hyperf-engine-swow)

PHPackages © 2026

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